From 10aafef351ea2270d4b864ae65743c2cd64b64ec Mon Sep 17 00:00:00 2001 From: Utsav Maniyar Date: Tue, 13 Jan 2026 07:41:32 -0700 Subject: [PATCH 1/2] chore(new-flag): added flag to list available modules --- docs/USAGE.md | 2 ++ pkg/config/structures.go | 1 + pkg/core/const.go | 1 + pkg/core/core.go | 1 + pkg/scan/ruleCfgReader.go | 8 ++++++++ 5 files changed, 13 insertions(+) diff --git a/docs/USAGE.md b/docs/USAGE.md index 6f0bc51..4e2ca26 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -109,6 +109,8 @@ Usage of go-earlybird: Set number of workers. (default 100) -worksize int Set Line Wrap Length. (default 2500) + -list-available-modules + List available scanning modules. This is useful when inporting configurations from a file and you want to know the module available to configure. -module-config-file string Absolute path to a json or yaml file for per module level config -- {"modules": { "aModule": { "display_severity": "medium" } } } ``` diff --git a/pkg/config/structures.go b/pkg/config/structures.go index fce0f1c..6e6462e 100755 --- a/pkg/config/structures.go +++ b/pkg/config/structures.go @@ -97,6 +97,7 @@ type EarlybirdConfig struct { ShowFullLine bool FailScan bool RulesOnly bool + ModuleOnly bool ExtensionsToSkipScan []string AnnotationsToSkipLine []string SkipComments bool diff --git a/pkg/core/const.go b/pkg/core/const.go index c7d7458..3f78f7f 100644 --- a/pkg/core/const.go +++ b/pkg/core/const.go @@ -59,6 +59,7 @@ var ( ptrShowFullLine = flag.Bool("show-full-line", false, "Display the full line where the pattern match was found (warning: this can be dangerous with minified script files)") ptrConfigDir = flag.String("config", utils.GetConfigDir(), "Directory where configuration files are stored") ptrRulesOnly = flag.Bool("show-rules-only", false, "Display rules that would be run, but do not execute a scan") + ptrAvailableModules = flag.Bool("list-available-modules", false, "Display modules that are available, but do not execute a scan") ptrSkipComments = flag.Bool("skip-comments", false, "Skip scanning comments in files -- applies only to the 'content' module") ptrIgnoreFPRules = flag.Bool("ignore-fp-rules", false, "Ignore the false positive post-process rules") ptrShowSolutions = flag.Bool("show-solutions", false, "Display recommended solution for each finding") diff --git a/pkg/core/core.go b/pkg/core/core.go index 1dcbacf..9382850 100644 --- a/pkg/core/core.go +++ b/pkg/core/core.go @@ -211,6 +211,7 @@ func (eb *EarlybirdCfg) ConfigInit() { eb.Config.IgnoreFailure = *ptrIgnoreFailure eb.Config.GitStream = *ptrGitStreamInput eb.Config.RulesOnly = *ptrRulesOnly + eb.Config.ModuleOnly = *ptrAvailableModules eb.Config.SkipComments = *ptrSkipComments eb.Config.IgnoreFPRules = *ptrIgnoreFPRules eb.Config.ShowSolutions = *ptrShowSolutions diff --git a/pkg/scan/ruleCfgReader.go b/pkg/scan/ruleCfgReader.go index 6f73ebb..84081bf 100755 --- a/pkg/scan/ruleCfgReader.go +++ b/pkg/scan/ruleCfgReader.go @@ -39,6 +39,14 @@ func Init(cfg cfgreader.EarlybirdConfig) { fmt.Println("Max file size to scan: ", cfg.MaxFileSize, " bytes") } + if cfg.ModuleOnly { + log.Println("Available modules: ") + for moduleName := range cfg.EnabledModulesMap { + log.Println(moduleName) + } + os.Exit(0) + } + // Init rule set for modules for moduleName, fileName := range cfg.EnabledModulesMap { log.Println("loading module: ", moduleName) From edb6cff9acd676aba2124e31bdd2970e252cbc11 Mon Sep 17 00:00:00 2001 From: Utsav Maniyar Date: Thu, 15 Jan 2026 08:00:24 -0700 Subject: [PATCH 2/2] chore(description): added description to all the module --- config/rules/ccnumber.yaml | 1 + config/rules/content.yaml | 1 + config/rules/filename.yaml | 1 + config/rules/inclusivity-rules.yaml | 1 + config/rules/password-secret.yaml | 1 + pkg/scan/ruleCfgReader.go | 16 +++++++++++++--- 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/config/rules/ccnumber.yaml b/config/rules/ccnumber.yaml index fd66d49..7bf0ac3 100644 --- a/config/rules/ccnumber.yaml +++ b/config/rules/ccnumber.yaml @@ -13,6 +13,7 @@ # permissions and limitations under the License. --- +description: This module identifies potential American Express credit card numbers in files. It uses a regular expression to match patterns that resemble American Express card numbers, which typically start with 34 or 37 and are 15 digits long. The rule also includes a post-processing step to validate the matched numbers using the Luhn algorithm (mod10). If a potential credit card number is found, it will be redacted in the output to protect sensitive information. Searcharea: body rules: - Code: 2001 diff --git a/config/rules/content.yaml b/config/rules/content.yaml index 18f5287..bd73b8b 100644 --- a/config/rules/content.yaml +++ b/config/rules/content.yaml @@ -13,6 +13,7 @@ # permissions and limitations under the License. --- +description: This module check for the presence of potential sensitive information in files. It uses a variety of regular expressions to identify patterns that may indicate the presence of sensitive data, such as keys, passwords, phone numbers, email addresses, IP addresses, social security numbers, national IDs, passport numbers, and deprecated cryptographic methods. The rules are designed to help identify potential security risks and protect sensitive information from being exposed. Each rule includes a post-processing step to further analyze the matched data and determine if it is indeed sensitive information. Searcharea: body rules: - Code: 3009 diff --git a/config/rules/filename.yaml b/config/rules/filename.yaml index e8db701..c479a79 100644 --- a/config/rules/filename.yaml +++ b/config/rules/filename.yaml @@ -13,6 +13,7 @@ # permissions and limitations under the License. --- +description: This module check for the presence of sensitive files and cryptographic keys based on filename patterns. It uses regular expressions to identify filenames that are commonly associated with private keys, configuration files, log files, database dumps, and other sensitive information. The rules in this module can help identify potential security risks where sensitive files may have been inadvertently included in a code repository or exposed in a file system. Each rule includes a severity level and confidence score to help prioritize findings. Searcharea: filename rules: - Code: 4001 diff --git a/config/rules/inclusivity-rules.yaml b/config/rules/inclusivity-rules.yaml index 15652de..20bffc0 100644 --- a/config/rules/inclusivity-rules.yaml +++ b/config/rules/inclusivity-rules.yaml @@ -13,6 +13,7 @@ # permissions and limitations under the License. --- +description: This module checks for the presence of the terms "whitelist", "blacklist", "master", and "slave" in code, which are considered oppressive metaphors. The use of these terms can perpetuate harmful stereotypes and contribute to an unwelcoming environment. The rules in this module aim to promote inclusivity by encouraging developers to use more neutral language in their coding practices. Searcharea: body rules: - Code: 20001 diff --git a/config/rules/password-secret.yaml b/config/rules/password-secret.yaml index ec2764e..8951908 100644 --- a/config/rules/password-secret.yaml +++ b/config/rules/password-secret.yaml @@ -13,6 +13,7 @@ # permissions and limitations under the License. --- +description: This module checks for passwords and secrets in files. It includes rules for identifying potential default passwords, as well as patterns that may indicate the presence of sensitive information such as API keys, access tokens, and database connection strings. The rules use regular expressions to match common naming conventions for passwords and secrets, and they also include post-processing steps to extract the relevant information for further analysis or redaction. Searcharea: body rules: - Code: 1002 diff --git a/pkg/scan/ruleCfgReader.go b/pkg/scan/ruleCfgReader.go index 84081bf..af81ee3 100755 --- a/pkg/scan/ruleCfgReader.go +++ b/pkg/scan/ruleCfgReader.go @@ -40,9 +40,19 @@ func Init(cfg cfgreader.EarlybirdConfig) { } if cfg.ModuleOnly { - log.Println("Available modules: ") - for moduleName := range cfg.EnabledModulesMap { - log.Println(moduleName) + fmt.Println("\n\nAvailable Module List") + for moduleName, fileName := range cfg.EnabledModulesMap { + // Load the module config file to get the description + var moduleConfig struct { + Description string `json:"description"` + } + modulePath := path.Join(cfg.RulesConfigDir, fileName) + err := cfgreader.LoadConfig(&moduleConfig, modulePath) + if err != nil { + log.Println("Failed to load module file for description:", err) + } else { + fmt.Printf("\n%s: \n%s \n", moduleName, moduleConfig.Description) + } } os.Exit(0) }