`<language>_enabled_rules` has no effect (bare IDs passed to `--exclude-rule`), and 7 Action default rule IDs no longer exist

Open
#135 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 3 days

@lelia is already working on this.

Since Nov 12, 2026.

  • #141 by @lelia — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
security, testing

Research direction

Start with socket_basics/core/connector/opengrep/__init__.py around lines 149–176 and 395–410, then compare the defaults in action.yml with socket_basics/connectors.yaml and the bundled rules. Reproduce the mismatch using tests/test_opengrep_custom_rules.py and the OpenGrep behavior described in the issue. Done means enabled rule filters match loaded rule IDs, Action defaults reference existing rules and stay aligned with CLI defaults, and a test verifies excluded rules produce no findings.

Written by the indexing model from the issue text.

Description

Summary

Two related defects in v3.4.1 (2ba1ad98). Both are still present on main: the three commits since the tag do not touch the OpenGrep connector or the *_enabled_rules defaults.

  1. <language>_enabled_rules does not narrow the scan. The OpenGrep connector turns the allowlist into --exclude-rule <id> flags using the rule IDs as written in the rules file. OpenGrep rewrites the ID of every rule it loads from a local config file to start with the file's directory path, and --exclude-rule only removes a rule whose rewritten ID is in the list. None of the flags ever matches, so every rule in the bundled file runs.
  2. Seven rule IDs in the Action's default *_enabled_rules lists are not defined in any bundled rules file, and those defaults no longer match the CLI defaults in connectors.yaml. Once (1) is fixed, Action users who never set the input would drop to a much smaller rule set than the CLI default. For JavaScript that is 6 rules, not 30.

What a run shows

GitHub Action v3.4.1 with javascript_sast_enabled: 'true' and no javascript_enabled_rules input, so the Action's 8-ID default applies. The step log:

Per-language enabled-rule filters detected: {'javascript_typescript.yml': 8}
Using bundled rules for javascript_typescript.yml from /socket-basics/socket_basics/rules/javascript_typescript.yml
Filtering rules for javascript_typescript.yml: 8 enabled IDs configured
Running OpenGrep: opengrep --json --dataflow-traces --output /tmp/... --quiet --config /socket-basics/socket_basics/rules/javascript_typescript.yml --exclude-rule js-missing-auth-check --exclude-rule ... /github/workspace

The command carries 53 --exclude-rule flags: the file's 59 rules minus the 6 default IDs that exist. The run still reported findings from rules on that list, for example js-react-dangerous-html and js-hardcoded-secret, and medium and low findings from rules outside the allowlist.

Why no exclusion matches

The image installs OpenGrep 1.26.0 (Dockerfile L11). In that version a local --config file is loaded like this:

The connector already expects prefixed IDs back. It strips everything before the last . from each result's check_id, and its comment lists socket-basics.socket_basics.rules.rule-name as one of the forms it sees (opengrep/__init__.py L395-L410). The exclusion list it builds uses the unprefixed IDs (L149-L176).

The same applies to custom rules, which are loaded from a temporary file outside the workspace, and to the CLI wherever the rules file is outside the working directory. Upgrading OpenGrep does not change it: the newer OCaml CLI keeps the same behaviour on purpose, "so an absolute config path outside the project still prefixes the rule ids with its directories" (Rule_fetching.ml L75-L86 on main).

The existing tests could not catch this because they assert the command line, not the result. tests/test_opengrep_custom_rules.py checks that --exclude-rule org.no-innerhtml appears in the arguments (L184-L185, L221-L222).

The Action defaults

The per-language *_enabled_rules defaults in action.yml are described as "high-confidence rules", but they differ from the CLI defaults in connectors.yaml, and seven of their IDs are not defined anywhere under socket_basics/rules/:

Input IDs in the default IDs that exist IDs that do not exist
javascript_enabled_rules (L287-L290) 8 6 js-eval-usage, js-weak-crypto-md5
python_enabled_rules (L375-L378) 11 8 python-exec-used, python-bad-file-permissions, python-hardcoded-password-string
ruby_enabled_rules (L387-L390) 9 7 ruby-rails-unsafe-constantize, ruby-xxe-vulnerability

Every ID in the connectors.yaml defaults exists; the JavaScript list there has 30 (L182-L187). The missing IDs look like names from before the ruleset rewrite in #13, for example js-eval-usage where the file now has js-code-injection-eval, and js-weak-crypto-md5 where it has js-weak-hash-md5.

Impact

  • <language>_enabled_rules cannot narrow a scan, so every bundled rule for the enabled languages runs. Scans are noisier and slower than configured, and the Filtering rules ... N enabled IDs configured log line reports a filter that is not applied.
  • Fixing the filter alone would change the result for every Action user who relies on the defaults. A JavaScript scan would go from all 59 rules to 6, and the eval and MD5 checks the default names were meant to include would be gone. Users who set all_rules_enabled: 'true' are not affected, because the connector clears the filter in that case.

Suggested fixes

  1. Make the filter independent of OpenGrep's ID rewriting. Either write a temporary copy of the rules file that contains only the enabled rules and pass that with --config, or pass --no-rewrite-rule-ids (commands/scan.py L252) so the plain IDs match.
  2. Add an end-to-end test that runs the bundled OpenGrep binary on a small fixture and asserts that an excluded rule produces no finding. An assertion on the arguments cannot catch this class of defect.
  3. Derive the Action defaults from connectors.yaml, or default the Action inputs to empty and let the connector defaults apply, and log a warning when a configured enabled or disabled ID matches no loaded rule.
  4. Ship 1 and 3 together and note the change of scope in the changelog.

Until then, all_rules_enabled: 'true' makes the current behaviour explicit, and <language>_disabled_rules does take effect, because the normaliser marks those findings ignore after the scan.

I could not run the image locally. The cause above is read from the OpenGrep 1.26.0 source and agrees with the run's log. One note for whoever checks it: the OCaml copy of the prefix function at the 1.26.0 tag would not prefix a path outside the working directory, but the scan in that version goes through the Python CLI linked above, and the run's behaviour matches the Python code.

Dominant language
Python
Stars
14
Forks
8
Avg merge
4d 22h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SocketDev/socket-basics

All issues in SocketDev/socket-basics

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.