From c858b11466043ed17212be831c346a50ec99fd40 Mon Sep 17 00:00:00 2001 From: Andrea Brancaleoni Date: Fri, 17 May 2024 17:08:31 +0200 Subject: [PATCH] generate-compound.rb: generate compound.yml file for cmd line tests --- assets/semgrep_rules/generate-compound.rb | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 assets/semgrep_rules/generate-compound.rb diff --git a/assets/semgrep_rules/generate-compound.rb b/assets/semgrep_rules/generate-compound.rb new file mode 100644 index 00000000..3af7d27f --- /dev/null +++ b/assets/semgrep_rules/generate-compound.rb @@ -0,0 +1,28 @@ +require 'yaml' + +SEMGREP_VERSION = `semgrep --version`.strip + +HOST = 'https://semgrep.dev' + +files = Dir['client/*.yaml', 'services/*.yaml', 'generated/*/vulns.yaml', 'generated/*/audit.yaml'] + +rules = {'rules' => []} + +files.each do |fname| + begin + irules = YAML.load(File.read(fname))['rules'] + puts "#{fname}: #{irules.length}" + + rules['rules'].concat irules + rescue + puts "Error in #{fname}" + end +end + +puts "#rules: #{rules['rules'].length}" + +File.write("compound.yaml", YAML.dump(rules)) + +# require 'pry' +# binding.pry +