mirror of
https://github.com/github/codeql-action.git
synced 2026-04-26 00:38:48 +00:00
Merge pull request #3806 from github/henrymercer/store-language-aliases
Store language aliases from linked CLI
This commit is contained in:
@@ -57,6 +57,20 @@ jobs:
|
||||
- name: Update bundle
|
||||
uses: ./.github/actions/update-bundle
|
||||
|
||||
- name: Set up CodeQL CLI from new bundle
|
||||
id: setup-codeql
|
||||
uses: ./setup-codeql
|
||||
with:
|
||||
tools: https://github.com/github/codeql-action/releases/download/${{ github.event.release.tag_name }}/codeql-bundle-linux64.tar.gz
|
||||
|
||||
- name: Update language aliases
|
||||
env:
|
||||
CODEQL_PATH: ${{ steps.setup-codeql.outputs.codeql-path }}
|
||||
run: |
|
||||
"$CODEQL_PATH" resolve languages --format=betterjson --extractor-include-aliases \
|
||||
| jq -S '.aliases // {}' \
|
||||
> src/known-language-aliases.json
|
||||
|
||||
- name: Bump Action minor version if new CodeQL minor version series
|
||||
id: bump-action-version
|
||||
run: |
|
||||
|
||||
Generated
+959
-930
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"c": "cpp",
|
||||
"c-c++": "cpp",
|
||||
"c-cpp": "cpp",
|
||||
"c#": "csharp",
|
||||
"c++": "cpp",
|
||||
"java-kotlin": "java",
|
||||
"javascript-typescript": "javascript",
|
||||
"kotlin": "java",
|
||||
"typescript": "javascript"
|
||||
}
|
||||
+12
-24
@@ -18,6 +18,7 @@ import {
|
||||
FeatureEnablement,
|
||||
} from "./feature-flags";
|
||||
import * as json from "./json";
|
||||
import * as knownLanguageAliases from "./known-language-aliases.json";
|
||||
import { KnownLanguage } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import {
|
||||
@@ -188,43 +189,30 @@ export const UPDATEJOB_PROXY_VERSION = "v2.0.20250624110901";
|
||||
const UPDATEJOB_PROXY_URL_PREFIX =
|
||||
"https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.22.0/";
|
||||
|
||||
/*
|
||||
* Language aliases supported by the start-proxy Action.
|
||||
*
|
||||
* In general, the CodeQL CLI is the source of truth for language aliases, and to
|
||||
* allow us to more easily support new languages, we want to avoid hardcoding these
|
||||
* aliases in the Action itself. However this is difficult to do in the start-proxy
|
||||
* Action since this Action does not use CodeQL, so we're accepting some hardcoding
|
||||
* for this Action.
|
||||
*/
|
||||
const LANGUAGE_ALIASES: { [lang: string]: KnownLanguage } = {
|
||||
c: KnownLanguage.cpp,
|
||||
"c++": KnownLanguage.cpp,
|
||||
"c#": KnownLanguage.csharp,
|
||||
kotlin: KnownLanguage.java,
|
||||
typescript: KnownLanguage.javascript,
|
||||
"javascript-typescript": KnownLanguage.javascript,
|
||||
"java-kotlin": KnownLanguage.java,
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the start-proxy language input into its canonical CodeQL language name.
|
||||
*
|
||||
* Exported for testing. Do not use this outside of the start-proxy Action
|
||||
* to avoid complicating the process of adding new CodeQL languages.
|
||||
* This uses the language aliases shipped with the Action and will not be able to resolve aliases
|
||||
* added by versions of the CodeQL CLI newer than the one mentioned in `defaults.json`. However,
|
||||
* this is sufficient for the start-proxy Action since we are already specifying proxy
|
||||
* configurations on a per-language basis.
|
||||
*/
|
||||
export function parseLanguage(language: string): KnownLanguage | undefined {
|
||||
// Normalize to lower case
|
||||
language = language.trim().toLowerCase();
|
||||
|
||||
// See if it's an exact match
|
||||
if (language in KnownLanguage) {
|
||||
if (Object.hasOwn(KnownLanguage, language)) {
|
||||
return language as KnownLanguage;
|
||||
}
|
||||
|
||||
// Check language aliases
|
||||
if (language in LANGUAGE_ALIASES) {
|
||||
return LANGUAGE_ALIASES[language];
|
||||
if (Object.hasOwn(knownLanguageAliases, language)) {
|
||||
language =
|
||||
knownLanguageAliases[language as keyof typeof knownLanguageAliases];
|
||||
if (Object.hasOwn(KnownLanguage, language)) {
|
||||
return language as KnownLanguage;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user