def verifyPackage(self): """Check if the binary is in changesfile and its name is valid.""" control_package = self.control.get("Package", '') # Since DDEBs are generated after the original DEBs are processed # and considered by `dpkg-genchanges` they are only half-incorporated # the binary upload changes file. DDEBs are only listed in the # Files/Checksums-Sha1/ChecksumsSha256 sections and missing from # Binary/Description. if not self.filename.endswith('.ddeb'): if control_package not in self.changes.binaries: yield UploadError( "%s: control file lists name as %r, which isn't in " "changes file." % (self.filename, control_package)) if not re_valid_pkg_name.match(control_package): yield UploadError("%s: invalid package name %r." % (self.filename, control_package)) # Ensure the filename matches the contents of the .deb # First check the file package name matches the deb contents. binary_match = re_isadeb.match(self.filename) file_package = binary_match.group(1) if control_package != file_package: yield UploadError("%s: package part of filename %r does not match " "package name in the control fields %r" % (self.filename, file_package, control_package))
def verifyPackage(self): """Check if the binary is in changesfile and its name is valid.""" control_package = self.control.get("Package", '') # Since DDEBs are generated after the original DEBs are processed # and considered by `dpkg-genchanges` they are only half-incorporated # the binary upload changes file. DDEBs are only listed in the # Files/Checksums-Sha1/ChecksumsSha256 sections and missing from # Binary/Description. if not self.filename.endswith('.ddeb'): if control_package not in self.changes.binaries: yield UploadError( "%s: control file lists name as %r, which isn't in " "changes file." % (self.filename, control_package)) if not re_valid_pkg_name.match(control_package): yield UploadError("%s: invalid package name %r." % ( self.filename, control_package)) # Ensure the filename matches the contents of the .deb # First check the file package name matches the deb contents. binary_match = re_isadeb.match(self.filename) file_package = binary_match.group(1) if control_package != file_package: yield UploadError( "%s: package part of filename %r does not match " "package name in the control fields %r" % (self.filename, file_package, control_package))
def verify(self): """Verify the uploaded .dsc file. This method is an error generator, i.e, it returns an iterator over all exceptions that are generated while processing DSC file checks. """ for error in SourceUploadFile.verify(self): yield error # Check size and checksum of the DSC file itself try: self.checkSizeAndCheckSum() except UploadError as error: yield error try: raw_files = parse_and_merge_file_lists(self._dict, changes=False) except UploadError as e: yield e return files = [] for attr in raw_files: filename, hashes, size = attr if not re_issource.match(filename): # DSC files only really hold on references to source # files; they are essentially a description of a source # package. Anything else is crack. yield UploadError("%s: File %s does not look sourceful." % (self.filename, filename)) continue filepath = os.path.join(self.dirname, filename) try: file_instance = DSCUploadedFile(filepath, hashes, size, self.policy, self.logger) except UploadError as error: yield error else: files.append(file_instance) self.files = files if not re_valid_pkg_name.match(self.source): yield UploadError("%s: invalid source name %s" % (self.filename, self.source)) if not re_valid_version.match(self.dsc_version): yield UploadError("%s: invalid version %s" % (self.filename, self.dsc_version)) if not self.policy.distroseries.isSourcePackageFormatPermitted( self.format): yield UploadError( "%s: format '%s' is not permitted in %s." % (self.filename, self.format, self.policy.distroseries.name)) # Validate the build dependencies for field_name in ['Build-Depends', 'Build-Depends-Indep']: field = self._dict.get(field_name, None) if field is not None: if field.startswith("ARRAY"): yield UploadError( "%s: invalid %s field produced by a broken version " "of dpkg-dev (1.10.11)" % (self.filename, field_name)) try: with warnings.catch_warnings(): warnings.simplefilter("error") PkgRelation.parse_relations(field) except Warning as error: yield UploadError( "%s: invalid %s field; cannot be parsed by deb822: %s" % (self.filename, field_name, error)) # Verify if version declared in changesfile is the same than that # in DSC (including epochs). if self.dsc_version != self.version: yield UploadError( "%s: version ('%s') in .dsc does not match version " "('%s') in .changes." % (self.filename, self.dsc_version, self.version)) for error in self.checkFiles(): yield error
def verify(self): """Verify the uploaded .dsc file. This method is an error generator, i.e, it returns an iterator over all exceptions that are generated while processing DSC file checks. """ for error in SourceUploadFile.verify(self): yield error # Check size and checksum of the DSC file itself try: self.checkSizeAndCheckSum() except UploadError as error: yield error try: raw_files = parse_and_merge_file_lists(self._dict, changes=False) except UploadError as e: yield e return files = [] for attr in raw_files: filename, hashes, size = attr if not re_issource.match(filename): # DSC files only really hold on references to source # files; they are essentially a description of a source # package. Anything else is crack. yield UploadError("%s: File %s does not look sourceful." % ( self.filename, filename)) continue filepath = os.path.join(self.dirname, filename) try: file_instance = DSCUploadedFile( filepath, hashes, size, self.policy, self.logger) except UploadError as error: yield error else: files.append(file_instance) self.files = files if not re_valid_pkg_name.match(self.source): yield UploadError( "%s: invalid source name %s" % (self.filename, self.source)) if not re_valid_version.match(self.dsc_version): yield UploadError( "%s: invalid version %s" % (self.filename, self.dsc_version)) if not self.policy.distroseries.isSourcePackageFormatPermitted( self.format): yield UploadError( "%s: format '%s' is not permitted in %s." % (self.filename, self.format, self.policy.distroseries.name)) # Validate the build dependencies for field_name in ['Build-Depends', 'Build-Depends-Indep']: field = self._dict.get(field_name, None) if field is not None: if field.startswith("ARRAY"): yield UploadError( "%s: invalid %s field produced by a broken version " "of dpkg-dev (1.10.11)" % (self.filename, field_name)) try: apt_pkg.parse_src_depends(field) except (SystemExit, KeyboardInterrupt): raise except Exception as error: # Swallow everything apt_pkg throws at us because # it is not desperately pythonic and can raise odd # or confusing exceptions at times and is out of # our control. yield UploadError( "%s: invalid %s field; cannot be parsed by apt: %s" % (self.filename, field_name, error)) # Verify if version declared in changesfile is the same than that # in DSC (including epochs). if self.dsc_version != self.version: yield UploadError( "%s: version ('%s') in .dsc does not match version " "('%s') in .changes." % (self.filename, self.dsc_version, self.version)) for error in self.checkFiles(): yield error