Skip to content

Commit

Permalink
Fix perf of ruby.lang.security
Browse files Browse the repository at this point in the history
In principle, for these rules, this:

```
...
def $METHOD
  ...
end
...
```

should be equivalent to just `...`, but the latter is much faster.

(Yet I'm not sure why the current form is so slow...)

test plan:
% semgrep -c hardcoded-secret-rsa-passphrase.yaml path/to/gitlabhq/app/models/ci/build.rb
Before the change, on a MacBook Pro (Apple M1), this took ~3s, after the change, ~0.1s.
% semgrep -c insufficient-rsa-key-size.yaml path/to/gitlabhq/app/models/ci/build.rb
Before the change, on a MacBook Pro (Apple M1), this took ~20s, after the change, ~0.1s.
  • Loading branch information
IagoAbal committed Oct 2, 2023
1 parent e81f323 commit 2b9f6c5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
4 changes: 0 additions & 4 deletions ruby/lang/security/hardcoded-secret-rsa-passphrase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ rules:
- pattern-inside: |
$ASSIGN = '...'
...
def $METHOD(...)
...
end
...
- pattern: OpenSSL::PKey::RSA.new(..., $ASSIGN)
- patterns:
- pattern-inside: |
Expand Down
8 changes: 0 additions & 8 deletions ruby/lang/security/insufficient-rsa-key-size.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ rules:
- pattern-inside: |
$ASSIGN = $SIZE
...
def $METHOD(...)
...
end
...
- pattern-either:
- pattern: OpenSSL::PKey::RSA.new($ASSIGN, ...)
- pattern: OpenSSL::PKey::RSA.generate($ASSIGN, ...)
Expand All @@ -46,10 +42,6 @@ rules:
...
end
...
def $METHOD2(...)
...
end
...
- pattern-either:
- pattern: OpenSSL::PKey::RSA.new($ASSIGN, ...)
- pattern: OpenSSL::PKey::RSA.generate($ASSIGN, ...)
Expand Down

0 comments on commit 2b9f6c5

Please sign in to comment.