Skip to content

Commit 76f245b

Browse files
author
Alvaro Muñoz
committed
feat(actions): use published actions packs
1 parent 8e59fb7 commit 76f245b

File tree

6 files changed

+27
-215
lines changed

6 files changed

+27
-215
lines changed

.github/action/dist/index.js

Lines changed: 12 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -28596,7 +28596,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
2859628596
return result;
2859728597
};
2859828598
Object.defineProperty(exports, "__esModule", ({ value: true }));
28599-
exports.codeqlDatabaseAnalyze = exports.codeqlDatabaseCreate = exports.installPack = exports.downloadPack = exports.runCommandJson = exports.runCommand = exports.newCodeQL = void 0;
28599+
exports.codeqlDatabaseAnalyze = exports.codeqlDatabaseCreate = exports.downloadPack = exports.runCommandJson = exports.runCommand = exports.newCodeQL = void 0;
2860028600
const fs = __importStar(__nccwpck_require__(7147));
2860128601
const path = __importStar(__nccwpck_require__(1017));
2860228602
const core = __importStar(__nccwpck_require__(2186));
@@ -28675,18 +28675,6 @@ async function downloadPack(codeql) {
2867528675
return false;
2867628676
}
2867728677
exports.downloadPack = downloadPack;
28678-
async function installPack(codeql, dir) {
28679-
try {
28680-
await runCommand(codeql, ["pack", "install"], path.join(dir, "/ql/lib"));
28681-
await runCommand(codeql, ["pack", "install"], path.join(dir, "/ql/src"));
28682-
return true;
28683-
}
28684-
catch (error) {
28685-
core.warning("Failed to install local packs ...");
28686-
}
28687-
return false;
28688-
}
28689-
exports.installPack = installPack;
2869028678
async function codeqlDatabaseCreate(codeql) {
2869128679
// get runner temp directory for database
2869228680
var temp = process.env["RUNNER_TEMP"];
@@ -28734,84 +28722,6 @@ async function codeqlDatabaseAnalyze(codeql, database_path) {
2873428722
exports.codeqlDatabaseAnalyze = codeqlDatabaseAnalyze;
2873528723

2873628724

28737-
/***/ }),
28738-
28739-
/***/ 1772:
28740-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
28741-
28742-
"use strict";
28743-
28744-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
28745-
if (k2 === undefined) k2 = k;
28746-
var desc = Object.getOwnPropertyDescriptor(m, k);
28747-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28748-
desc = { enumerable: true, get: function() { return m[k]; } };
28749-
}
28750-
Object.defineProperty(o, k2, desc);
28751-
}) : (function(o, m, k, k2) {
28752-
if (k2 === undefined) k2 = k;
28753-
o[k2] = m[k];
28754-
}));
28755-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28756-
Object.defineProperty(o, "default", { enumerable: true, value: v });
28757-
}) : function(o, v) {
28758-
o["default"] = v;
28759-
});
28760-
var __importStar = (this && this.__importStar) || function (mod) {
28761-
if (mod && mod.__esModule) return mod;
28762-
var result = {};
28763-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28764-
__setModuleDefault(result, mod);
28765-
return result;
28766-
};
28767-
Object.defineProperty(exports, "__esModule", ({ value: true }));
28768-
exports.clonePackRepo = exports.runCommandJson = exports.runCommand = exports.newGHConfig = void 0;
28769-
const path = __importStar(__nccwpck_require__(1017));
28770-
const core = __importStar(__nccwpck_require__(2186));
28771-
const toolrunner = __importStar(__nccwpck_require__(8159));
28772-
async function newGHConfig() {
28773-
return {
28774-
path: "/usr/bin/",
28775-
};
28776-
}
28777-
exports.newGHConfig = newGHConfig;
28778-
async function runCommand(config, args) {
28779-
var bin = path.join(config.path, "gh");
28780-
let output = "";
28781-
var options = {
28782-
listeners: {
28783-
stdout: (data) => {
28784-
output += data.toString();
28785-
},
28786-
},
28787-
};
28788-
await new toolrunner.ToolRunner(bin, args, options).exec();
28789-
core.debug(`Finished running command :: ${bin} ${args.join(" ")}`);
28790-
return output.trim();
28791-
}
28792-
exports.runCommand = runCommand;
28793-
async function runCommandJson(config, args) {
28794-
return JSON.parse(await runCommand(config, args));
28795-
}
28796-
exports.runCommandJson = runCommandJson;
28797-
async function clonePackRepo(gh, path) {
28798-
try {
28799-
await runCommand(gh, [
28800-
"repo",
28801-
"clone",
28802-
"GitHubSecurityLab/codeql-actions",
28803-
path,
28804-
]);
28805-
return true;
28806-
}
28807-
catch (error) {
28808-
core.warning("Failed to clone pack from GitHub...");
28809-
}
28810-
return false;
28811-
}
28812-
exports.clonePackRepo = clonePackRepo;
28813-
28814-
2881528725
/***/ }),
2881628726

2881728727
/***/ 6144:
@@ -28847,17 +28757,12 @@ exports.run = void 0;
2884728757
const path = __importStar(__nccwpck_require__(1017));
2884828758
const core = __importStar(__nccwpck_require__(2186));
2884928759
const cql = __importStar(__nccwpck_require__(950));
28850-
const gh = __importStar(__nccwpck_require__(1772));
2885128760
/**
2885228761
* The main function for the action.
2885328762
* @returns {Promise<void>} Resolves when the action is complete.
2885428763
*/
2885528764
async function run() {
2885628765
try {
28857-
// set up gh
28858-
var ghc = await gh.newGHConfig();
28859-
core.debug(`GH CLI found at '${ghc.path}'`);
28860-
await gh.runCommand(ghc, ["version"]);
2886128766
// set up codeql
2886228767
var codeql = await cql.newCodeQL();
2886328768
core.debug(`CodeQL CLI found at '${codeql.path}'`);
@@ -28873,21 +28778,17 @@ async function run() {
2887328778
core.setFailed("CodeQL Yaml extractor not installed");
2887428779
throw new Error("CodeQL Yaml extractor not installed");
2887528780
}
28876-
core.info(`Cloning CodeQL Actions pack into '${codeql.pack}'`);
28877-
let pack_path = "/tmp/codeql-actions";
28878-
var pack_cloned = await gh.clonePackRepo(ghc, pack_path);
28879-
core.info(`Cloned CodeQL Actions pack into '${pack_path}'`);
28880-
if (pack_cloned === false) {
28881-
throw new Error("Could not clone the actions ql pack");
28882-
}
28883-
core.info(`Installing CodeQL Actions packs from '${pack_path}'`);
28884-
var pack_installed = await cql.installPack(codeql, pack_path);
28885-
if (pack_installed === false) {
28886-
throw new Error("Could not install the actions ql packs");
28887-
}
28888-
core.info(`Pack path: '${pack_path}'`);
28889-
codeql.pack = path.join(pack_path, "ql", "src");
28890-
core.info(`Codeql Queries pack path: '${codeql.pack}'`);
28781+
// download pack
28782+
core.info(`Downloading CodeQL IaC pack '${codeql.pack}'`);
28783+
var pack_downloaded = await cql.downloadPack(codeql);
28784+
if (pack_downloaded === false) {
28785+
var action_path = path.resolve(path.join(__dirname, "..", "..", ".."));
28786+
codeql.pack = path.join(action_path, "ql", "src");
28787+
core.info(`Pack defaulting back to local pack: '${codeql.pack}'`);
28788+
}
28789+
else {
28790+
core.info(`Pack downloaded '${codeql.pack}'`);
28791+
}
2889128792
core.info("Creating CodeQL database...");
2889228793
var database_path = await cql.codeqlDatabaseCreate(codeql);
2889328794
core.info("Running CodeQL analysis...");

.github/action/src/codeql.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,6 @@ export async function downloadPack(codeql: CodeQLConfig): Promise<boolean> {
106106
return false;
107107
}
108108

109-
export async function installPack(
110-
codeql: CodeQLConfig,
111-
dir: string,
112-
): Promise<boolean> {
113-
try {
114-
await runCommand(codeql, ["pack", "install"], path.join(dir, "/ql/lib"));
115-
await runCommand(codeql, ["pack", "install"], path.join(dir, "/ql/src"));
116-
return true;
117-
} catch (error) {
118-
core.warning("Failed to install local packs ...");
119-
}
120-
return false;
121-
}
122-
123109
export async function codeqlDatabaseCreate(
124110
codeql: CodeQLConfig,
125111
): Promise<string> {

.github/action/src/gh.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/action/src/index.ts

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
import * as path from "path";
22
import * as core from "@actions/core";
33
import * as cql from "./codeql";
4-
import * as gh from "./gh";
54

65
/**
76
* The main function for the action.
87
* @returns {Promise<void>} Resolves when the action is complete.
98
*/
109
export async function run(): Promise<void> {
1110
try {
12-
// set up gh
13-
var ghc = await gh.newGHConfig();
14-
15-
core.debug(`GH CLI found at '${ghc.path}'`);
16-
17-
await gh.runCommand(ghc, ["version"]);
18-
1911
// set up codeql
2012
var codeql = await cql.newCodeQL();
2113

@@ -36,26 +28,19 @@ export async function run(): Promise<void> {
3628
throw new Error("CodeQL Yaml extractor not installed");
3729
}
3830

39-
core.info(`Cloning CodeQL Actions pack into '${codeql.pack}'`);
40-
let pack_path = "/tmp/codeql-actions";
41-
var pack_cloned = await gh.clonePackRepo(ghc, pack_path);
42-
core.info(`Cloned CodeQL Actions pack into '${pack_path}'`);
31+
// download pack
32+
core.info(`Downloading CodeQL IaC pack '${codeql.pack}'`);
33+
var pack_downloaded = await cql.downloadPack(codeql);
4334

44-
if (pack_cloned === false) {
45-
throw new Error("Could not clone the actions ql pack");
46-
}
47-
48-
core.info(`Installing CodeQL Actions packs from '${pack_path}'`);
49-
var pack_installed = await cql.installPack(codeql, pack_path);
35+
if (pack_downloaded === false) {
36+
var action_path = path.resolve(path.join(__dirname, "..", "..", ".."));
37+
codeql.pack = path.join(action_path, "ql", "src");
5038

51-
if (pack_installed === false) {
52-
throw new Error("Could not install the actions ql packs");
39+
core.info(`Pack defaulting back to local pack: '${codeql.pack}'`);
40+
} else {
41+
core.info(`Pack downloaded '${codeql.pack}'`);
5342
}
5443

55-
core.info(`Pack path: '${pack_path}'`);
56-
codeql.pack = path.join(pack_path, "ql", "src");
57-
core.info(`Codeql Queries pack path: '${codeql.pack}'`);
58-
5944
core.info("Creating CodeQL database...");
6045
var database_path = await cql.codeqlDatabaseCreate(codeql);
6146

.github/workflows/build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v4
18-
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50
18+
- uses: dorny/paths-filter@v3
1919
id: changes
2020
with:
2121
filters: |
@@ -26,5 +26,3 @@ jobs:
2626
- name: Run action
2727
if: steps.changes.outputs.src == 'true'
2828
uses: ./
29-
with:
30-
extractor-version: latest

ql/lib/codeql/actions/DataFlow.qll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ module DataFlow {
77
private import codeql.actions.dataflow.internal.DataFlowImplSpecific
88
import DataFlowMake<ActionsDataFlow>
99
import codeql.actions.dataflow.internal.DataFlowPublic
10-
11-
/** debug */
10+
// debug
1211
private import codeql.actions.dataflow.internal.TaintTrackingImplSpecific
1312
import codeql.dataflow.internal.DataFlowImplConsistency as DFIC
13+
1414
module ActionsConsistency implements DFIC::InputSig<ActionsDataFlow> { }
15+
1516
module Consistency {
16-
import DFIC::MakeConsistency<ActionsDataFlow, ActionsTaintTracking, ActionsConsistency>
17-
}
17+
import DFIC::MakeConsistency<ActionsDataFlow, ActionsTaintTracking, ActionsConsistency>
18+
}
1819
}

0 commit comments

Comments
 (0)