diff --git a/CHANGELOG.md b/CHANGELOG.md index 812d4b65e..2e5adf53d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,9 +22,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), This fixes a bug in v0.20.0 where provenance entries from an extensible enumerator could _only_ be JSON objects, instead of arbitrary JSON values as claimed by the documentation. +### Fixes +- The `Blynk Organization Client Credentials` rule now has a non-varying number of capture groups ### Changes - The `Slack Bot Token` rule has been modified to match additional cases. +- The `rules check` command now more thoroughly checks the number of capture groups of each rule ### Additions - New rules have been added: diff --git a/crates/noseyparker-cli/src/cmd_rules/cmd_rules_check.rs b/crates/noseyparker-cli/src/cmd_rules/cmd_rules_check.rs index bbea87082..c55c49666 100644 --- a/crates/noseyparker-cli/src/cmd_rules/cmd_rules_check.rs +++ b/crates/noseyparker-cli/src/cmd_rules/cmd_rules_check.rs @@ -223,9 +223,16 @@ fn check_rule(rule: &Rule, args: &RulesCheckArgs) -> Result { } Ok(pat) => { // Check that the rule has at least one capture group - if pat.captures_len() <= 1 { - error!("Rule has no capture groups"); - num_errors += 1; + match pat.static_captures_len() { + Some(0) => { + error!("Rule has no capture groups"); + num_errors += 1; + } + Some(_len) => {} + None => { + error!("Rule has a variable number of capture groups"); + num_errors += 1; + } } let mut num_succeeded = 0; diff --git a/crates/noseyparker-cli/tests/rules/snapshots/test_noseyparker__rules__rules_list_json-2.snap b/crates/noseyparker-cli/tests/rules/snapshots/test_noseyparker__rules__rules_list_json-2.snap index d0f02b923..0d08f70f6 100644 --- a/crates/noseyparker-cli/tests/rules/snapshots/test_noseyparker__rules__rules_list_json-2.snap +++ b/crates/noseyparker-cli/tests/rules/snapshots/test_noseyparker__rules__rules_list_json-2.snap @@ -553,12 +553,12 @@ expression: stdout }, { "id": "np.blynk.9", - "structural_id": "61027ac6a0bd9260330393485339d3012565b1b0", + "structural_id": "c6cec8b505fc62859dde26fd04c1656d6ab79286", "name": "Blynk Organization Client Credentials", "syntax": { "name": "Blynk Organization Client Credentials", "id": "np.blynk.9", - "pattern": "(?x)\n\\b\n(oa2-client-id_[a-zA-Z0-9_\\-]{32})\n:([a-zA-Z0-9_\\-]{40})\n[\\s\\\\]*https://(fra1\\.|lon1\\.|ny3\\.|sgp1\\.|blr1\\.)*blynk\\.cloud/oauth2\n", + "pattern": "(?x)\n\\b\n(oa2-client-id_[a-zA-Z0-9_\\-]{32})\n:([a-zA-Z0-9_\\-]{40})\n[\\s\\\\]*https://(?:fra1\\.|lon1\\.|ny3\\.|sgp1\\.|blr1\\.)*blynk\\.cloud/oauth2\n", "description": null, "examples": [ "curl -X POST -u oa2-client-id_zmNtW-D0Toqpz4AZnBLCIlklBrz9ynU-:5uC5Y4Mcvdl5rB56rBmxnvB4DZgiIpcyTPbOoEWp https://fra1.blynk.cloud/oauth2/token?grant_type=client_credentials", diff --git a/crates/noseyparker/data/default/builtin/rules/blynk.yml b/crates/noseyparker/data/default/builtin/rules/blynk.yml index ed885d28d..a6f6fbcf1 100644 --- a/crates/noseyparker/data/default/builtin/rules/blynk.yml +++ b/crates/noseyparker/data/default/builtin/rules/blynk.yml @@ -105,7 +105,7 @@ rules: \b (oa2-client-id_[a-zA-Z0-9_\-]{32}) :([a-zA-Z0-9_\-]{40}) - [\s\\]*https://(fra1\.|lon1\.|ny3\.|sgp1\.|blr1\.)*blynk\.cloud/oauth2 + [\s\\]*https://(?:fra1\.|lon1\.|ny3\.|sgp1\.|blr1\.)*blynk\.cloud/oauth2 categories: - api