Skip to content

Commit

Permalink
Remove masking logic
Browse files Browse the repository at this point in the history
  • Loading branch information
juliendoutre committed Feb 5, 2025
1 parent 09fe976 commit 2343238
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions guarddog/analyzer/sourcecode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ def get_sourcecode_rules(
ecosystem: The ecosystem to filter for if rules are ecosystem specific
kind: The kind of rule to filter for
"""
if ecosystem == ECOSYSTEM.GITHUB_ACTION:
ecosystem = ECOSYSTEM.NPM

for rule in SOURCECODE_RULES:
if kind and not isinstance(rule, kind):
continue
Expand All @@ -74,34 +71,36 @@ def get_sourcecode_rules(
data = yaml.load(fd, Loader=SafeLoader)
for rule in data["rules"]:
for lang in rule["languages"]:
ecosystem = None
ecosystems = set()
match lang:
case "python":
ecosystem = ECOSYSTEM.PYPI
ecosystems.add(ECOSYSTEM.PYPI)
case "javascript" | "typescript" | "json":
ecosystem = ECOSYSTEM.NPM
ecosystems.add(ECOSYSTEM.NPM)
ecosystems.add(ECOSYSTEM.GITHUB_ACTION)
case "go":
ecosystem = ECOSYSTEM.GO
ecosystems.add(ECOSYSTEM.GO)
case _:
continue

# avoids duplicates when multiple languages are supported by a rule
if not next(
filter(
lambda r: r.id == rule["id"],
get_sourcecode_rules(ecosystem, SempgrepRule),
),
None,
):
SOURCECODE_RULES.append(
SempgrepRule(
id=rule["id"],
ecosystem=ecosystem,
description=rule.get("metadata", {}).get("description", ""),
file=file_name,
rule_content=rule,
for ecosystem in ecosystems:
# avoids duplicates when multiple languages are supported by a rule
if not next(
filter(
lambda r: r.id == rule["id"],
get_sourcecode_rules(ecosystem, SempgrepRule),
),
None,
):
SOURCECODE_RULES.append(
SempgrepRule(
id=rule["id"],
ecosystem=ecosystem,
description=rule.get("metadata", {}).get("description", ""),
file=file_name,
rule_content=rule,
)
)
)

yara_rule_file_names = list(
filter(lambda x: x.endswith("yar"), os.listdir(current_dir))
Expand Down

0 comments on commit 2343238

Please sign in to comment.