Skip to content

Commit 6132b2c

Browse files
authored
Merge pull request #34 from esben-semmle/js/twitter_text-library
Approved by xiemaisi
2 parents 6e7b3ad + a025daf commit 6132b2c

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,41 @@ private class ApplicationInsights extends FrameworkLibraryWithURLRegex {
843843
}
844844
}
845845

846+
/**
847+
* The twitter-text framework.
848+
*/
849+
private class TwitterText extends FrameworkLibraryWithGenericURL, FrameworkLibraryWithMarkerComment {
850+
TwitterText() { this = "twitter-text" }
851+
852+
override string getAMarkerCommentRegex() {
853+
result = "(?s).*twitter-text\\s*(<VERSION>).*"
854+
}
855+
}
856+
857+
/**
858+
* The classic version of twitter-text, as seen in the wild.
859+
*/
860+
private class TwitterTextClassic extends FrameworkLibraryWithURLRegex {
861+
TwitterTextClassic() { this = "twitter-text" }
862+
863+
override string getAURLRegex() {
864+
result = ".*(?:^|/)twitter_text" + variantRegex() + "\\.js"
865+
}
866+
}
867+
868+
/**
869+
* A copy of twitter-text.
870+
*/
871+
private class TwitterTextClassicInstance extends FrameworkLibraryInstance {
872+
TwitterTextClassicInstance() {
873+
this.(TopLevel).getFile().getAbsolutePath().regexpMatch(any(TwitterTextClassic t).getAURLRegex())
874+
}
875+
override predicate info(FrameworkLibrary fl, string v) {
876+
fl instanceof TwitterTextClassic and
877+
v = ""
878+
}
879+
}
880+
846881
/**
847882
* A `FrameworkLibraryReference` that refers to a recognised `FrameworkLibraryInstance`,
848883
* 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
| tmpl.html:0:0:0:0 | tmpl.html | template |
2020
| tst.browserify.js:0:0:0:0 | tst.browserify.js | generated |
2121
| tst.dart.js:0:0:0:0 | tst.dart.js | generated |
22+
| twitter-text.js:0:0:0:0 | twitter-text.js | library |
23+
| twitter_text.js:0:0:0:0 | twitter_text.js | library |
2224
| unannotated-externs-1.js:0:0:0:0 | unannotated-externs-1.js | externs |
2325
| unannotated-externs-2.js:0:0:0:0 | unannotated-externs-2.js | externs |
2426
| unannotated-externs-3.js:0:0:0:0 | unannotated-externs-3.js | externs |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*!
2+
* twitter-text 2.0.4
3+
*
4+
* Copyright 2012 Twitter, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this work except in compliance with the License.
8+
* You may obtain a copy of the License at:
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// classic version of twitter-text, as seen in the wild

0 commit comments

Comments
 (0)