Merge pull request #19854 from Napalys/js/sinon

JS: Explicitly Mark `Sinon` Package as Non RegExp
This commit is contained in:
Napalys Klicius
2025-06-24 10:24:13 +02:00
committed by GitHub
4 changed files with 16 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Calls to `sinon.match()` are no longer incorrectly identified as regular expression operations.

View File

@@ -998,6 +998,8 @@ private predicate isUsedAsNonMatchObject(DataFlow::MethodCallNode call) {
or
// Result is obviously unused
call.asExpr() = any(ExprStmt stmt).getExpr()
or
call = API::moduleImport("sinon").getMember("match").getACall()
)
}

View File

@@ -60,4 +60,8 @@
/^(foo.example\.com|whatever)$/; // $ Alert (but kinda OK - one disjunction doesn't even look like a hostname)
if (s.matchAll("^http://test.example.com")) {} // $ Alert
const sinon = require('sinon');
const megacliteUrl = "https://a.b.com";
sinon.assert.calledWith(postStub.firstCall, sinon.match(megacliteUrl));
});

View File

@@ -0,0 +1,6 @@
const sinon = require('sinon');
function testFunction() {
const megacliteUrl = "https://a.b.com";
sinon.assert.calledWith(postStub.firstCall, sinon.match(megacliteUrl));
}