Skip to content

Commit 2218a98

Browse files
authored
Merge pull request #19854 from Napalys/js/sinon
JS: Explicitly Mark `Sinon` Package as Non RegExp
2 parents e8a08a6 + 33f4244 commit 2218a98

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Calls to `sinon.match()` are no longer incorrectly identified as regular expression operations.

javascript/ql/lib/semmle/javascript/Regexp.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,8 @@ private predicate isUsedAsNonMatchObject(DataFlow::MethodCallNode call) {
998998
or
999999
// Result is obviously unused
10001000
call.asExpr() = any(ExprStmt stmt).getExpr()
1001+
or
1002+
call = API::moduleImport("sinon").getMember("match").getACall()
10011003
)
10021004
}
10031005

javascript/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegExp/tst-IncompleteHostnameRegExp.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,8 @@
6060
/^(foo.example\.com|whatever)$/; // $ Alert (but kinda OK - one disjunction doesn't even look like a hostname)
6161

6262
if (s.matchAll("^http://test.example.com")) {} // $ Alert
63+
64+
const sinon = require('sinon');
65+
const megacliteUrl = "https://a.b.com";
66+
sinon.assert.calledWith(postStub.firstCall, sinon.match(megacliteUrl));
6367
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const sinon = require('sinon');
2+
3+
function testFunction() {
4+
const megacliteUrl = "https://a.b.com";
5+
sinon.assert.calledWith(postStub.firstCall, sinon.match(megacliteUrl));
6+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy