mirror of
https://github.com/github/codeql-action.git
synced 2025-12-30 11:10:22 +08:00
Fix auto-detection of extractors that aren't languages
This commit is contained in:
@@ -63,6 +63,7 @@ function createTestInitConfigInputs(
|
||||
async betterResolveLanguages() {
|
||||
return {
|
||||
extractors: {
|
||||
html: [{ extractor_root: "" }],
|
||||
javascript: [{ extractor_root: "" }],
|
||||
},
|
||||
};
|
||||
@@ -1125,6 +1126,20 @@ const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
expectedApiCall: false,
|
||||
expectedError: configUtils.getUnknownLanguagesError(["a", "b"]),
|
||||
},
|
||||
{
|
||||
name: "extractors that aren't languages aren't included (specified)",
|
||||
languagesInput: "html",
|
||||
languagesInRepository: [],
|
||||
expectedApiCall: false,
|
||||
expectedError: configUtils.getUnknownLanguagesError(["html"]),
|
||||
},
|
||||
{
|
||||
name: "extractors that aren't languages aren't included (autodetected)",
|
||||
languagesInput: "",
|
||||
languagesInRepository: ["html", "javascript"],
|
||||
expectedApiCall: true,
|
||||
expectedLanguages: ["javascript"],
|
||||
},
|
||||
].forEach((args) => {
|
||||
test(`getLanguages: ${args.name}`, async (t) => {
|
||||
const mockRequest = mockLanguagesInRepo(args.languagesInRepository);
|
||||
|
||||
@@ -310,7 +310,13 @@ export async function getSupportedLanguageMap(
|
||||
const supportedLanguages: Record<string, string> = {};
|
||||
// Populate canonical language names
|
||||
for (const extractor of Object.keys(resolveResult.extractors)) {
|
||||
supportedLanguages[extractor] = extractor;
|
||||
// Require the language to be a known language.
|
||||
// This is a temporary workaround since we have extractors that are not
|
||||
// supported languages, such as `csv`, `html`, `properties`, `xml`, and
|
||||
// `yaml`. We should replace this with a more robust solution in the future.
|
||||
if (KnownLanguage[extractor] !== undefined) {
|
||||
supportedLanguages[extractor] = extractor;
|
||||
}
|
||||
}
|
||||
// Populate language aliases
|
||||
if (resolveResult.aliases) {
|
||||
|
||||
@@ -8,8 +8,9 @@ export type Language = string;
|
||||
* languages do not need to be added here.
|
||||
*/
|
||||
export enum KnownLanguage {
|
||||
csharp = "csharp",
|
||||
actions = "actions",
|
||||
cpp = "cpp",
|
||||
csharp = "csharp",
|
||||
go = "go",
|
||||
java = "java",
|
||||
javascript = "javascript",
|
||||
|
||||
Reference in New Issue
Block a user