Skip to content

Commit 2e5d9c3

Browse files
authored
Merge pull request github#16675 from mbaluda/main
Extract .xsaccess files as JSON
2 parents ef2f016 + cc02717 commit 2e5d9c3

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
* <li>Files with base name "package.json" or "tsconfig.json", and files whose base name
160160
* is of the form "codeql-javascript-*.json".
161161
* <li>JavaScript, JSON or YAML files whose base name starts with ".eslintrc".
162+
* <li>JSON files whose base name is ".xsaccess".
162163
* <li>All extension-less files.
163164
* </ul>
164165
*
@@ -393,9 +394,10 @@ private void setupFilters() {
393394
for (FileType filetype : defaultExtract)
394395
for (String extension : filetype.getExtensions()) patterns.add("**/*" + extension);
395396

396-
// include .eslintrc files, package.json files, tsconfig.json files, and
397-
// codeql-javascript-*.json files
397+
// include .eslintrc files, .xsaccess files, package.json files,
398+
// tsconfig.json files, and codeql-javascript-*.json files
398399
patterns.add("**/.eslintrc*");
400+
patterns.add("**/.xsaccess");
399401
patterns.add("**/package.json");
400402
patterns.add("**/tsconfig*.json");
401403
patterns.add("**/codeql-javascript-*.json");

javascript/extractor/src/com/semmle/js/extractor/FileExtractor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ protected boolean contains(File f, String lcExt, ExtractorConfig config) {
184184
if (super.contains(f, lcExt, config)) return true;
185185

186186
// detect JSON-encoded configuration files whose name starts with `.` and ends with `rc`
187-
// (e.g., `.eslintrc` or `.babelrc`)
188-
if (f.isFile() && f.getName().matches("\\..*rc")) {
187+
// (e.g., `.eslintrc` or `.babelrc`) as well as `.xsaccess` files
188+
if (f.isFile() && f.getName().matches("\\..*rc|\\.xsaccess")) {
189189
try (BufferedReader br = new BufferedReader(new FileReader(f))) {
190190
// check whether the first two non-empty lines look like the start of a JSON object
191191
// (two lines because the opening brace is usually on a line by itself)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"exposed": true // Expose data via http
3+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#10000=@"/.xsaccess;sourcefile"
2+
files(#10000,"/.xsaccess")
3+
#10001=@"/;folder"
4+
folders(#10001,"/")
5+
containerparent(#10001,#10000)
6+
#10002=@"loc,{#10000},0,0,0,0"
7+
locations_default(#10002,#10000,0,0,0,0)
8+
hasLocation(#10000,#10002)
9+
#20000=*
10+
json(#20000,5,#10000,0,"{\n ""ex ... http\n}")
11+
#20001=@"loc,{#10000},1,1,3,1"
12+
locations_default(#20001,#10000,1,1,3,1)
13+
json_locations(#20000,#20001)
14+
#20002=*
15+
json(#20002,1,#20000,0,"true")
16+
#20003=@"loc,{#10000},2,14,2,17"
17+
locations_default(#20003,#10000,2,14,2,17)
18+
json_locations(#20002,#20003)
19+
json_literals("true","true",#20002)
20+
json_properties(#20000,"exposed",#20002)
21+
numlines(#10000,3,0,0)
22+
filetype(#10000,"json")

0 commit comments

Comments
 (0)