@@ -76,6 +76,45 @@ def test_scan_uses_custom_rule_file_when_available(tmp_path, monkeypatch):
7676 assert str (bundled_rules_dir / "javascript_typescript.yml" ) not in cmd_str
7777
7878
79+ def test_all_languages_custom_rules_without_individual_language_flags (tmp_path , monkeypatch ):
80+ workspace = tmp_path / "workspace"
81+ workspace .mkdir (parents = True , exist_ok = True )
82+
83+ custom_rules_file = workspace / ".socket" / "rules" / "org-rules.yml"
84+ _write_custom_rules_file (custom_rules_file , ["org.no-eval" ])
85+
86+ bundled_rules_dir = tmp_path / "bundled-rules"
87+ bundled_js_file = bundled_rules_dir / "javascript_typescript.yml"
88+ bundled_python_file = bundled_rules_dir / "python.yml"
89+ _write_rule_file (bundled_js_file , ["js-default-rule" ])
90+ _write_rule_file (bundled_python_file , ["py-default-rule" ])
91+
92+ config = Config (
93+ {
94+ "workspace" : str (workspace ),
95+ "output_dir" : str (workspace ),
96+ "all_languages_enabled" : True ,
97+ "use_custom_sast_rules" : True ,
98+ "custom_sast_rule_path" : ".socket/rules" ,
99+ "opengrep_rules_dir" : str (bundled_rules_dir ),
100+ "all_rules_enabled" : False ,
101+ "verbose" : False ,
102+ }
103+ )
104+ scanner = OpenGrepScanner (config )
105+ scanner ._convert_to_socket_facts = lambda _ : {"components" : []}
106+ scanner .generate_notifications = lambda _ : {}
107+
108+ captured_cmd : list [str ] = []
109+ _mock_subprocess_run (monkeypatch , captured_cmd )
110+ scanner .scan ()
111+
112+ cmd_str = " " .join (captured_cmd )
113+ assert "socket_custom_rules_" in cmd_str
114+ assert str (bundled_js_file ) not in cmd_str
115+ assert str (bundled_python_file ) in cmd_str
116+
117+
79118def test_scan_falls_back_to_bundled_file_when_custom_missing (tmp_path , monkeypatch ):
80119 workspace = tmp_path / "workspace"
81120 workspace .mkdir (parents = True , exist_ok = True )
0 commit comments