Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
not p.startswith('debuginfo(') and
p not in useless_provides):
useless_provides.add(p)
for p in sorted(useless_provides):
self.output.add_info('E', pkg, 'useless-provides', p)
for tagname, items in (
('Provides', pkg.provides),
('Conflicts', pkg.conflicts),
('Obsoletes', pkg.obsoletes),
('Supplements', pkg.supplements),
('Suggests', pkg.suggests),
('Enhances', pkg.enhances),
('Recommends', pkg.recommends)):
for p in items:
e = Pkg.has_forbidden_controlchars(p)
if e:
self.output.add_info('E',
pkg,
'forbidden-controlchar-found',
'%s: %s' % (tagname, e))
value = Pkg.formatRequire(*p)
self._unexpanded_macros(pkg, '%s %s' % (tagname, value), value)
for p in (pkg.requires):
e = Pkg.has_forbidden_controlchars(p)
if e:
self.output.add_info('E',
pkg,
'forbidden-controlchar-found',
'Requires: %s' % e)
res = prereq_regex.search(line)
if res:
self.output.add_info('E', pkg, 'prereq-use', res.group(2))
res = buildprereq_regex.search(line)
if res:
self.output.add_info('E', pkg, 'buildprereq-use', res.group(1))
if scriptlet_requires_regex.search(line):
self.output.add_info('E', pkg, 'broken-syntax-in-scriptlet-requires',
line.strip())
res = requires_regex.search(line)
if res:
reqs = Pkg.parse_deps(res.group(1))
e = Pkg.has_forbidden_controlchars(reqs)
if e:
self.output.add_info('E', pkg,
'forbidden-controlchar-found',
'Requires: %s' % e)
for req in unversioned(reqs):
if compop_regex.search(req):
self.output.add_info('W', pkg,
'comparison-operator-in-deptoken',
req)
res = provides_regex.search(line)
if res:
provs = Pkg.parse_deps(res.group(1))
e = Pkg.has_forbidden_controlchars(provs)
if e:
self.output.add_info('E', pkg,
self.output.add_info('E', pkg,
'forbidden-controlchar-found',
'Obsoletes: %s' % e)
for obs in unversioned(obses):
if not obs.startswith('/'):
self.output.add_info('W', pkg, 'unversioned-explicit-obsoletes',
obs)
if compop_regex.search(obs):
self.output.add_info('W', pkg,
'comparison-operator-in-deptoken',
obs)
res = conflicts_regex.search(line)
if res:
confs = Pkg.parse_deps(res.group(1))
e = Pkg.has_forbidden_controlchars(confs)
if e:
self.output.add_info('E', pkg,
'forbidden-controlchar-found',
'Conflicts: %s' % e)
for conf in unversioned(confs):
if compop_regex.search(conf):
self.output.add_info('W', pkg,
'comparison-operator-in-deptoken',
conf)
if current_section == 'changelog':
e = Pkg.has_forbidden_controlchars(line)
if e:
self.output.add_info('E', pkg,
'forbidden-controlchar-found',
'%%changelog: %s' % e)
self.output.add_info('E', pkg,
'forbidden-controlchar-found',
'Provides: %s' % e)
for prov in unversioned(provs):
if not prov.startswith('/'):
self.output.add_info('W', pkg, 'unversioned-explicit-provides',
prov)
if compop_regex.search(prov):
self.output.add_info('W', pkg,
'comparison-operator-in-deptoken',
prov)
res = obsoletes_regex.search(line)
if res:
obses = Pkg.parse_deps(res.group(1))
e = Pkg.has_forbidden_controlchars(obses)
if e:
self.output.add_info('E', pkg,
'forbidden-controlchar-found',
'Obsoletes: %s' % e)
for obs in unversioned(obses):
if not obs.startswith('/'):
self.output.add_info('W', pkg, 'unversioned-explicit-obsoletes',
obs)
if compop_regex.search(obs):
self.output.add_info('W', pkg,
'comparison-operator-in-deptoken',
obs)
res = conflicts_regex.search(line)
if res:
confs = Pkg.parse_deps(res.group(1))
reqs = Pkg.parse_deps(res.group(1))
e = Pkg.has_forbidden_controlchars(reqs)
if e:
self.output.add_info('E', pkg,
'forbidden-controlchar-found',
'Requires: %s' % e)
for req in unversioned(reqs):
if compop_regex.search(req):
self.output.add_info('W', pkg,
'comparison-operator-in-deptoken',
req)
res = provides_regex.search(line)
if res:
provs = Pkg.parse_deps(res.group(1))
e = Pkg.has_forbidden_controlchars(provs)
if e:
self.output.add_info('E', pkg,
'forbidden-controlchar-found',
'Provides: %s' % e)
for prov in unversioned(provs):
if not prov.startswith('/'):
self.output.add_info('W', pkg, 'unversioned-explicit-provides',
prov)
if compop_regex.search(prov):
self.output.add_info('W', pkg,
'comparison-operator-in-deptoken',
prov)
res = obsoletes_regex.search(line)
if res:
obses = Pkg.parse_deps(res.group(1))
res = conflicts_regex.search(line)
if res:
confs = Pkg.parse_deps(res.group(1))
e = Pkg.has_forbidden_controlchars(confs)
if e:
self.output.add_info('E', pkg,
'forbidden-controlchar-found',
'Conflicts: %s' % e)
for conf in unversioned(confs):
if compop_regex.search(conf):
self.output.add_info('W', pkg,
'comparison-operator-in-deptoken',
conf)
if current_section == 'changelog':
e = Pkg.has_forbidden_controlchars(line)
if e:
self.output.add_info('E', pkg,
'forbidden-controlchar-found',
'%%changelog: %s' % e)
for match in self.macro_regex.findall(line):
res = re.match('%+', match)
if len(res.group(0)) % 2:
self.output.add_info('W', pkg, 'macro-in-%changelog', match)
else:
if not depscript_override:
depscript_override = \
depscript_override_regex.search(line) is not None
if not depgen_disabled:
depgen_disabled = \
depgen_disable_regex.search(line) is not None
if not patch_fuzz_override:
# the extension is often a macro or otherwise dynamic.
if self.release_ext:
expected.append(self.extension_regex.sub('', expected[0]))
if ret.group(1) not in expected:
if len(expected) == 1:
expected = expected[0]
self.output.add_info('W', pkg, 'incoherent-version-in-changelog',
ret.group(1), expected)
if clt:
changelog = changelog + clt
for s in changelog:
if not Pkg.is_utf8_bytestr(s):
self.output.add_info('E', pkg, 'tag-not-utf8', '%changelog')
break
e = Pkg.has_forbidden_controlchars(s)
if e:
self.output.add_info('E', pkg, 'forbidden-controlchar-found', '%%changelog : %s' % e)
break
clt = pkg[rpm.RPMTAG_CHANGELOGTIME][0]
if clt:
clt -= clt % (24 * 3600) # roll back to 00:00:00, see #246
if clt < oldest_changelog_timestamp:
self.output.add_info('W', pkg, 'changelog-time-overflow',
time.strftime('%Y-%m-%d', time.gmtime(clt)))
elif clt > time.time():
self.output.add_info('E', pkg, 'changelog-time-in-future',
time.strftime('%Y-%m-%d', time.gmtime(clt)))
def split_license(text):
return (x.strip() for x in