Skip to content

Commit

Permalink
Improve rules check and fix a rule typo
Browse files Browse the repository at this point in the history
  • Loading branch information
bradlarsen committed Dec 9, 2024
1 parent 4d6a38f commit fb766d9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 10 additions & 3 deletions crates/noseyparker-cli/src/cmd_rules/cmd_rules_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,16 @@ fn check_rule(rule: &Rule, args: &RulesCheckArgs) -> Result<CheckStats> {
}
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion crates/noseyparker/data/default/builtin/rules/blynk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fb766d9

Please sign in to comment.