mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
Extract .xsaccess files as JSON
This commit is contained in:
@@ -159,6 +159,7 @@ import com.semmle.util.trap.TrapWriter;
|
||||
* <li>Files with base name "package.json" or "tsconfig.json", and files whose base name
|
||||
* is of the form "codeql-javascript-*.json".
|
||||
* <li>JavaScript, JSON or YAML files whose base name starts with ".eslintrc".
|
||||
* <li>JSON files whose base name is ".xsaccess".
|
||||
* <li>All extension-less files.
|
||||
* </ul>
|
||||
*
|
||||
@@ -393,9 +394,10 @@ public class AutoBuild {
|
||||
for (FileType filetype : defaultExtract)
|
||||
for (String extension : filetype.getExtensions()) patterns.add("**/*" + extension);
|
||||
|
||||
// include .eslintrc files, package.json files, tsconfig.json files, and
|
||||
// codeql-javascript-*.json files
|
||||
// include .eslintrc files, .xaccess files, package.json files,
|
||||
// tsconfig.json files, and codeql-javascript-*.json files
|
||||
patterns.add("**/.eslintrc*");
|
||||
patterns.add("**/.xaccess");
|
||||
patterns.add("**/package.json");
|
||||
patterns.add("**/tsconfig*.json");
|
||||
patterns.add("**/codeql-javascript-*.json");
|
||||
|
||||
@@ -184,8 +184,8 @@ public class FileExtractor {
|
||||
if (super.contains(f, lcExt, config)) return true;
|
||||
|
||||
// detect JSON-encoded configuration files whose name starts with `.` and ends with `rc`
|
||||
// (e.g., `.eslintrc` or `.babelrc`)
|
||||
if (f.isFile() && f.getName().matches("\\..*rc")) {
|
||||
// (e.g., `.eslintrc` or `.babelrc`) as well as `.xsaccess` files
|
||||
if (f.isFile() && f.getName().matches("\\..*rc|\\.xsaccess")) {
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(f))) {
|
||||
// check whether the first two non-empty lines look like the start of a JSON object
|
||||
// (two lines because the opening brace is usually on a line by itself)
|
||||
|
||||
@@ -461,8 +461,10 @@ public class AutoBuildTests {
|
||||
|
||||
@Test
|
||||
public void hiddenFiles() throws IOException {
|
||||
Path eslintrc = addFile(true, LGTM_SRC, ".eslintrc.json");
|
||||
Path eslintrc = addFile(true, LGTM_SRC, ".eslintrc.json", ".xsaccess");
|
||||
hide(eslintrc);
|
||||
Path xsaccess = addFile(true, LGTM_SRC, ".xsaccess");
|
||||
hide(xsaccess);
|
||||
runTest();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user