Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2589cf7

Browse files
author
Esben Sparre Andreasen
committed
JS: classify the ApplicationInsights library instance
1 parent 87f9ecb commit 2589cf7

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

javascript/ql/src/semmle/javascript/dependencies/FrameworkLibraries.qll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,33 @@ private class RequireJS extends FrameworkLibraryWithGenericURL, FrameworkLibrary
816816
}
817817
}
818818

819+
/**
820+
* A copy of the Microsoft ApplicationInsights framework.
821+
*/
822+
private class ApplicationInsightsInstance extends FrameworkLibraryInstance {
823+
string version;
824+
825+
ApplicationInsightsInstance() {
826+
version = this.(TopLevel).getFile().getAbsolutePath().regexpCapture(any(ApplicationInsights t).getAURLRegex(), 1)
827+
}
828+
829+
override predicate info(FrameworkLibrary fl, string v) {
830+
fl instanceof ApplicationInsights and
831+
version = v
832+
}
833+
}
834+
835+
/**
836+
* The Microsoft ApplicationInsights framework.
837+
*/
838+
private class ApplicationInsights extends FrameworkLibraryWithURLRegex {
839+
ApplicationInsights() { this = "ApplicationInsights" }
840+
841+
override string getAURLRegex() {
842+
result = ".*(?:^|/)ai\\.(" + semverRegex() + ")-build\\d+\\.js"
843+
}
844+
}
845+
819846
/**
820847
* A `FrameworkLibraryReference` that refers to a recognised `FrameworkLibraryInstance`,
821848
* that is, a `<script>` tag where the `src` attribute can be resolved to a local file

javascript/ql/test/query-tests/filters/ClassifyFiles/ClassifyFiles.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
| ai.1.2.3-build0123.js:0:0:0:0 | ai.1.2.3-build0123.js | library |
12
| bundle-directive.js:0:0:0:0 | bundle-directive.js | generated |
23
| jison-lex.js:0:0:0:0 | jison-lex.js | generated |
34
| jison.js:0:0:0:0 | jison.js | generated |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)