Skip to content

Commit

Permalink
Merge pull request #477 from DataDog/s.obregoso/improve_npm-exfiltrat…
Browse files Browse the repository at this point in the history
…e-sensitive-data

Fix os usage case in npm-exfiltrate-sensitive-data
  • Loading branch information
sobregosodd authored Oct 28, 2024
2 parents 8bb9532 + f56b403 commit ac05ae9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions guarddog/analyzer/sourcecode/npm-exfiltrate-sensitive-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ rules:
- patterns:
- pattern-either:
- pattern: process.env

- patterns:
- pattern-either: # after defining fs
- pattern-inside: |
$OS = require('os')
...
- pattern-either:
# match use of ootb functions
- pattern: $OS. ... .homedir()
- pattern: $OS. ... .hostname()
- pattern: $OS. ... .userInfo()


- patterns:
- pattern-either: # after defining fs
- pattern-inside: |
Expand All @@ -31,11 +44,6 @@ rules:
import $FS from 'fs/promises'
...
- pattern-either:
# match use of ootb functions
- pattern: $FS. ... .homedir()
- pattern: $FS. ... .hostname()
- pattern: $FS. ... .userInfo()

# match access to sensitive files
- patterns:
- pattern-either:
Expand Down
4 changes: 2 additions & 2 deletions tests/analyzer/sourcecode/npm-exfiltrate-sensitive-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function f(){
}

function f(){
os = require('fs');
os = require('os');
https = require('https');
const td = {
c: __dirname,
Expand Down Expand Up @@ -112,4 +112,4 @@ function f(){
//process.stdout.write(d);
});
});
}
}

0 comments on commit ac05ae9

Please sign in to comment.