GeezerVison is showing github.com — Fix auto-detection of extractors that aren't languages · github/codeql-action@5794ffc
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/config-utils.js +7-1Lines changed: 7 additions & 1 deletion Collapse file Copy file name to clipboardExpand all lines: lib/config-utils.js.map +1-1Lines changed: 1 addition & 1 deletion Collapse file Copy file name to clipboardExpand all lines: lib/config-utils.test.js +15Lines changed: 15 additions & 0 deletions Collapse file Copy file name to clipboardExpand all lines: lib/config-utils.test.js.map +1-1Lines changed: 1 addition & 1 deletion Collapse file Copy file name to clipboardExpand all lines: lib/languages.js +2-1Lines changed: 2 additions & 1 deletion Collapse file Copy file name to clipboardExpand all lines: lib/languages.js.map +1-1Lines changed: 1 addition & 1 deletion Collapse file Copy file name to clipboardExpand all lines: src/config-utils.test.ts +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -63,6 +63,7 @@ function createTestInitConfigInputs( | 63 | 63 | async betterResolveLanguages() { | 64 | 64 | return { | 65 | 65 | extractors: { | | 66 | + html: [{ extractor_root: "" }], | 66 | 67 | javascript: [{ extractor_root: "" }], | 67 | 68 | }, | 68 | 69 | }; | @@ -1125,6 +1126,20 @@ const mockRepositoryNwo = parseRepositoryNwo("owner/repo"); | 1125 | 1126 | expectedApiCall: false, | 1126 | 1127 | expectedError: configUtils.getUnknownLanguagesError(["a", "b"]), | 1127 | 1128 | }, | | 1129 | + { | | 1130 | + name: "extractors that aren't languages aren't included (specified)", | | 1131 | + languagesInput: "html", | | 1132 | + languagesInRepository: [], | | 1133 | + expectedApiCall: false, | | 1134 | + expectedError: configUtils.getUnknownLanguagesError(["html"]), | | 1135 | + }, | | 1136 | + { | | 1137 | + name: "extractors that aren't languages aren't included (autodetected)", | | 1138 | + languagesInput: "", | | 1139 | + languagesInRepository: ["html", "javascript"], | | 1140 | + expectedApiCall: true, | | 1141 | + expectedLanguages: ["javascript"], | | 1142 | + }, | 1128 | 1143 | ].forEach((args) => { | 1129 | 1144 | test(`getLanguages: ${args.name}`, async (t) => { | 1130 | 1145 | const mockRequest = mockLanguagesInRepo(args.languagesInRepository); | |
Collapse file Copy file name to clipboardExpand all lines: src/config-utils.ts +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -310,7 +310,13 @@ export async function getSupportedLanguageMap( | 310 | 310 | const supportedLanguages: Record<string, string> = {}; | 311 | 311 | // Populate canonical language names | 312 | 312 | for (const extractor of Object.keys(resolveResult.extractors)) { | 313 | | - supportedLanguages[extractor] = extractor; | | 313 | + // Require the language to be a known language. | | 314 | + // This is a temporary workaround since we have extractors that are not | | 315 | + // supported languages, such as `csv`, `html`, `properties`, `xml`, and | | 316 | + // `yaml`. We should replace this with a more robust solution in the future. | | 317 | + if (KnownLanguage[extractor] !== undefined) { | | 318 | + supportedLanguages[extractor] = extractor; | | 319 | + } | 314 | 320 | } | 315 | 321 | // Populate language aliases | 316 | 322 | if (resolveResult.aliases) { | |
Collapse file Copy file name to clipboardExpand all lines: src/languages.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,8 +8,9 @@ export type Language = string; | 8 | 8 | * languages do not need to be added here. | 9 | 9 | */ | 10 | 10 | export enum KnownLanguage { | 11 | | - csharp = "csharp", | | 11 | + actions = "actions", | 12 | 12 | cpp = "cpp", | | 13 | + csharp = "csharp", | 13 | 14 | go = "go", | 14 | 15 | java = "java", | 15 | 16 | javascript = "javascript", | |
|