Skip to content

Commit 465d7f6

Browse files
Merge pull request #3 from Contrast-Security-OSS/PRODSEC-461-build
Migration build
2 parents cc32ccf + 4882543 commit 465d7f6

File tree

3 files changed

+182
-161
lines changed

3 files changed

+182
-161
lines changed

lib/index.js

Lines changed: 72 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,19 +3557,19 @@ var __copyProps = (to, from, except, desc) => {
35573557
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35583558

35593559
// pkg/dist-src/index.js
3560-
var dist_src_exports = {};
3561-
__export(dist_src_exports, {
3560+
var index_exports = {};
3561+
__export(index_exports, {
35623562
Octokit: () => Octokit
35633563
});
3564-
module.exports = __toCommonJS(dist_src_exports);
3564+
module.exports = __toCommonJS(index_exports);
35653565
var import_universal_user_agent = __nccwpck_require__(3843);
35663566
var import_before_after_hook = __nccwpck_require__(2732);
35673567
var import_request = __nccwpck_require__(8636);
35683568
var import_graphql = __nccwpck_require__(7);
35693569
var import_auth_token = __nccwpck_require__(7864);
35703570

35713571
// pkg/dist-src/version.js
3572-
var VERSION = "5.2.0";
3572+
var VERSION = "5.2.1";
35733573

35743574
// pkg/dist-src/index.js
35753575
var noop = () => {
@@ -17139,7 +17139,7 @@ module.exports = {
1713917139

1714017140

1714117141
const { parseSetCookie } = __nccwpck_require__(8915)
17142-
const { stringify, getHeadersList } = __nccwpck_require__(3834)
17142+
const { stringify } = __nccwpck_require__(3834)
1714317143
const { webidl } = __nccwpck_require__(4222)
1714417144
const { Headers } = __nccwpck_require__(6349)
1714517145

@@ -17215,14 +17215,13 @@ function getSetCookies (headers) {
1721517215

1721617216
webidl.brandCheck(headers, Headers, { strict: false })
1721717217

17218-
const cookies = getHeadersList(headers).cookies
17218+
const cookies = headers.getSetCookie()
1721917219

1722017220
if (!cookies) {
1722117221
return []
1722217222
}
1722317223

17224-
// In older versions of undici, cookies is a list of name:value.
17225-
return cookies.map((pair) => parseSetCookie(Array.isArray(pair) ? pair[1] : pair))
17224+
return cookies.map((pair) => parseSetCookie(pair))
1722617225
}
1722717226

1722817227
/**
@@ -17650,14 +17649,15 @@ module.exports = {
1765017649
/***/ }),
1765117650

1765217651
/***/ 3834:
17653-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
17652+
/***/ ((module) => {
1765417653

1765517654
"use strict";
1765617655

1765717656

17658-
const assert = __nccwpck_require__(2613)
17659-
const { kHeadersList } = __nccwpck_require__(6443)
17660-
17657+
/**
17658+
* @param {string} value
17659+
* @returns {boolean}
17660+
*/
1766117661
function isCTLExcludingHtab (value) {
1766217662
if (value.length === 0) {
1766317663
return false
@@ -17918,31 +17918,13 @@ function stringify (cookie) {
1791817918
return out.join('; ')
1791917919
}
1792017920

17921-
let kHeadersListNode
17922-
17923-
function getHeadersList (headers) {
17924-
if (headers[kHeadersList]) {
17925-
return headers[kHeadersList]
17926-
}
17927-
17928-
if (!kHeadersListNode) {
17929-
kHeadersListNode = Object.getOwnPropertySymbols(headers).find(
17930-
(symbol) => symbol.description === 'headers list'
17931-
)
17932-
17933-
assert(kHeadersListNode, 'Headers cannot be parsed')
17934-
}
17935-
17936-
const headersList = headers[kHeadersListNode]
17937-
assert(headersList)
17938-
17939-
return headersList
17940-
}
17941-
1794217921
module.exports = {
1794317922
isCTLExcludingHtab,
17944-
stringify,
17945-
getHeadersList
17923+
validateCookieName,
17924+
validateCookiePath,
17925+
validateCookieValue,
17926+
toIMFDate,
17927+
stringify
1794617928
}
1794717929

1794817930

@@ -21946,6 +21928,7 @@ const {
2194621928
isValidHeaderName,
2194721929
isValidHeaderValue
2194821930
} = __nccwpck_require__(5523)
21931+
const util = __nccwpck_require__(9023)
2194921932
const { webidl } = __nccwpck_require__(4222)
2195021933
const assert = __nccwpck_require__(2613)
2195121934

@@ -22499,6 +22482,9 @@ Object.defineProperties(Headers.prototype, {
2249922482
[Symbol.toStringTag]: {
2250022483
value: 'Headers',
2250122484
configurable: true
22485+
},
22486+
[util.inspect.custom]: {
22487+
enumerable: false
2250222488
}
2250322489
})
2250422490

@@ -31675,6 +31661,20 @@ class Pool extends PoolBase {
3167531661
? { ...options.interceptors }
3167631662
: undefined
3167731663
this[kFactory] = factory
31664+
31665+
this.on('connectionError', (origin, targets, error) => {
31666+
// If a connection error occurs, we remove the client from the pool,
31667+
// and emit a connectionError event. They will not be re-used.
31668+
// Fixes https://github.com/nodejs/undici/issues/3895
31669+
for (const target of targets) {
31670+
// Do not use kRemoveClient here, as it will close the client,
31671+
// but the client cannot be closed in this state.
31672+
const idx = this[kClients].indexOf(target)
31673+
if (idx !== -1) {
31674+
this[kClients].splice(idx, 1)
31675+
}
31676+
}
31677+
})
3167831678
}
3167931679

3168031680
[kGetDispatcher] () {
@@ -38808,16 +38808,16 @@ const github = __nccwpck_require__(847);
3880838808
function getFilesInCommit(commit, token) {
3880938809
return __awaiter(this, void 0, void 0, function* () {
3881038810
const repo = github.context.payload.repository;
38811-
console.log('repo : ' + repo);
38811+
console.log("repo : " + repo);
3881238812
const owner = repo === null || repo === void 0 ? void 0 : repo.owner;
38813-
console.log('owner : ' + owner);
38813+
console.log("owner : " + owner);
3881438814
const allFiles = [];
3881538815
const args = { owner: (owner === null || owner === void 0 ? void 0 : owner.name) || (owner === null || owner === void 0 ? void 0 : owner.login), repo: repo === null || repo === void 0 ? void 0 : repo.name };
3881638816
args.ref = commit.id || commit.sha;
3881738817
const octokit = github.getOctokit(token);
38818-
console.log('octokit : ' + octokit);
38819-
const result = yield octokit.repos.getCommit(args);
38820-
console.log('result : ' + result);
38818+
console.log("octokit : " + octokit);
38819+
const result = yield octokit.rest.repos.getCommit(args);
38820+
console.log("result : " + result);
3882138821
if (result && result.data && result.data.files) {
3882238822
const files = result.data.files;
3882338823
files
@@ -38894,19 +38894,19 @@ const core = __nccwpck_require__(7484);
3889438894
class Action {
3889538895
constructor(actionString) {
3889638896
actionString = actionString.toLowerCase();
38897-
let as = actionString.split('/');
38897+
let as = actionString.split("/");
3889838898
this.author = as[0];
38899-
let action = as[1].split('@');
38899+
let action = as[1].split("@");
3890038900
this.name = action[0];
38901-
this.ref = (action.length > 1) ? action[1] : "*";
38901+
this.ref = action.length > 1 ? action[1] : "*";
3890238902
}
3890338903
toString() {
3890438904
return `${this.author}/${this.name}@${this.ref}`;
3890538905
}
3890638906
}
3890738907
exports.Action = Action;
3890838908
function isPolicyResponse(obj) {
38909-
return typeof obj === 'object' && obj !== null && Array.isArray(obj.actions);
38909+
return typeof obj === "object" && obj !== null && Array.isArray(obj.actions);
3891038910
}
3891138911
function run(context) {
3891238912
return __awaiter(this, void 0, void 0, function* () {
@@ -38930,22 +38930,22 @@ function run(context) {
3893038930
// Get the pull request number
3893138931
const prNumber = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.number;
3893238932
if (prNumber) {
38933-
console.log('prNumber : ' + prNumber);
38933+
console.log("prNumber : " + prNumber);
3893438934
// Fetch the pull request details to get the commits_url
38935-
const prDetails = yield client.pulls.get({
38935+
const prDetails = yield client.rest.pulls.get({
3893638936
owner: github.context.repo.owner,
3893738937
repo: github.context.repo.repo,
3893838938
pull_number: prNumber,
3893938939
});
38940-
console.log('prDetails : ' + prDetails);
38940+
console.log("prDetails : " + prDetails);
3894138941
// Use the commits_url to fetch commits related to the pull request
3894238942
const url = prDetails.data.commits_url;
38943-
console.log('url : ' + url);
38943+
console.log("url : " + url);
3894438944
commits = yield client.paginate(`GET ${url}`, {
3894538945
owner: github.context.repo.owner,
3894638946
repo: github.context.repo.repo,
3894738947
});
38948-
console.log('commits : ' + commits);
38948+
console.log("commits : " + commits);
3894938949
}
3895038950
else {
3895138951
console.error("Pull request number not found in payload.");
@@ -38956,22 +38956,22 @@ function run(context) {
3895638956
// Get the pull request number
3895738957
const prNumber2 = (_b = github.context.payload.pull_request) === null || _b === void 0 ? void 0 : _b.number;
3895838958
if (prNumber2) {
38959-
console.log('prNumber2 : ' + prNumber2);
38959+
console.log("prNumber2 : " + prNumber2);
3896038960
// Fetch the pull request details to get the commits_url
38961-
const prDetails2 = yield client.pulls.get({
38961+
const prDetails2 = yield client.rest.pulls.get({
3896238962
owner: github.context.repo.owner,
3896338963
repo: github.context.repo.repo,
3896438964
pull_number: prNumber2,
3896538965
});
38966-
console.log('prDetails : ' + prDetails2);
38966+
console.log("prDetails : " + prDetails2);
3896738967
// Use the commits_url to fetch commits related to the pull request
3896838968
const url2 = prDetails2.data.commits_url;
38969-
console.log('url2 : ' + url2);
38969+
console.log("url2 : " + url2);
3897038970
commits = yield client.paginate(`GET ${url2}`, {
3897138971
owner: github.context.repo.owner,
3897238972
repo: github.context.repo.repo,
3897338973
});
38974-
console.log('commits : ' + commits);
38974+
console.log("commits : " + commits);
3897538975
}
3897638976
else {
3897738977
console.error("Pull request number not found in payload.");
@@ -38983,7 +38983,7 @@ function run(context) {
3898338983
}
3898438984
for (let i = 0; i < commits.length; i++) {
3898538985
var f = yield ghf.getFilesInCommit(commits[i], gitHubToken);
38986-
f.forEach(element => allFiles.add(element));
38986+
f.forEach((element) => allFiles.add(element));
3898738987
}
3898838988
let actionPolicyList = new Array();
3898938989
let actionViolations = new Array();
@@ -38992,8 +38992,9 @@ function run(context) {
3899238992
//look for any workflow file updates
3899338993
allFiles.forEach((file) => {
3899438994
let filePath = path_1.default.parse(file);
38995-
console.log('filePath : ' + filePath);
38996-
if ((filePath.ext.toLowerCase() == ".yaml" || filePath.ext.toLowerCase() == ".yml") &&
38995+
console.log("filePath : " + filePath);
38996+
if ((filePath.ext.toLowerCase() == ".yaml" ||
38997+
filePath.ext.toLowerCase() == ".yml") &&
3899738998
filePath.dir.toLowerCase() == ".github/workflows") {
3899838999
workflowFilePaths.push(file);
3899939000
}
@@ -39005,28 +39006,29 @@ function run(context) {
3900539006
}
3900639007
// Load up the remote policy list
3900739008
yield (0, node_fetch_1.default)(policyUrl)
39008-
.then(response => response.json())
39009+
.then((response) => response.json())
3900939010
.then((json) => {
39010-
json.actions.forEach(as => {
39011+
// json is now correctly typed as PolicyResponse
39012+
json.actions.forEach((as) => {
3901139013
actionPolicyList.push(new Action(as));
3901239014
});
3901339015
})
39014-
.catch(error => {
39015-
console.error('Error fetching or parsing policy:', error);
39016+
.catch((error) => {
39017+
console.error("Error fetching or parsing policy:", error);
3901639018
// Handle the error appropriately (e.g., throw an error, set a default policy)
3901739019
});
3901839020
console.log("\nACTION POLICY LIST");
3901939021
console.log(line);
3902039022
actionPolicyList.forEach((item) => {
3902139023
console.log(item.toString());
3902239024
});
39023-
workflowFilePaths.forEach(wf => {
39025+
workflowFilePaths.forEach((wf) => {
3902439026
let workflow = { filePath: wf, actions: Array() };
3902539027
workflowFiles.push(workflow);
3902639028
try {
3902739029
let yaml = js_yaml_1.default.load(fs_1.default.readFileSync(workflow.filePath, "utf-8"));
3902839030
let actionStrings = getPropertyValues(yaml, "uses");
39029-
actionStrings.forEach(as => {
39031+
actionStrings.forEach((as) => {
3903039032
workflow.actions.push(new Action(as));
3903139033
});
3903239034
}
@@ -39047,12 +39049,15 @@ function run(context) {
3904739049
workflowFiles.forEach((workflow) => {
3904839050
console.log(`\nEvaluating '${workflow.filePath}'`);
3904939051
console.log(line);
39050-
let violation = { filePath: workflow.filePath, actions: Array() };
39052+
let violation = {
39053+
filePath: workflow.filePath,
39054+
actions: Array(),
39055+
};
3905139056
workflow.actions.forEach((action) => {
3905239057
console.log(` - ${action.toString()}`);
3905339058
if (action.author == ".")
3905439059
return;
39055-
let match = actionPolicyList.find(policy => policy.author === action.author &&
39060+
let match = actionPolicyList.find((policy) => policy.author === action.author &&
3905639061
(policy.name === "*" || action.name === policy.name) &&
3905739062
(policy.ref === "*" || action.ref == policy.ref));
3905839063
if (policyType == "allow") {
@@ -39077,9 +39082,9 @@ function run(context) {
3907739082
core.setOutput("violations", actionViolations);
3907839083
console.log("\n!!! ACTION POLICY VIOLATIONS DETECTED !!!");
3907939084
console.log(line);
39080-
actionViolations.forEach(workflow => {
39085+
actionViolations.forEach((workflow) => {
3908139086
console.log(`Workflow: ${workflow.filePath}`);
39082-
workflow.actions.forEach(action => {
39087+
workflow.actions.forEach((action) => {
3908339088
console.log(` - ${action.toString()}`);
3908439089
});
3908539090
console.log();

src/github_files.ts

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1-
const github = require('@actions/github');
1+
const github = require("@actions/github");
22

3-
export async function getFilesInCommit(commit: any, token: string): Promise<string[]> {
3+
export async function getFilesInCommit(
4+
commit: any,
5+
token: string,
6+
): Promise<string[]> {
7+
const repo = github.context.payload.repository;
8+
console.log("repo : " + repo);
9+
const owner = repo?.owner;
10+
console.log("owner : " + owner);
11+
const allFiles: string[] = [];
412

5-
const repo = github.context.payload.repository;
6-
console.log('repo : ' + repo);
7-
const owner = repo?.owner;
8-
console.log('owner : ' + owner);
9-
const allFiles: string[] = [];
13+
const args: any = { owner: owner?.name || owner?.login, repo: repo?.name };
14+
args.ref = commit.id || commit.sha;
1015

11-
const args: any = { owner: owner?.name || owner?.login, repo: repo?.name };
12-
args.ref = commit.id || commit.sha;
16+
const octokit = github.getOctokit(token);
17+
console.log("octokit : " + octokit);
18+
const result = await octokit.rest.repos.getCommit(args);
19+
console.log("result : " + result);
1320

14-
const octokit = github.getOctokit(token);
15-
console.log('octokit : ' + octokit);
16-
const result = await octokit.rest.repos.getCommit(args);
17-
console.log('result : ' + result);
21+
if (result && result.data && result.data.files) {
22+
const files = result.data.files;
1823

19-
if (result && result.data && result.data.files) {
20-
const files = result.data.files;
21-
24+
files
25+
.filter(
26+
(file: { status: string; filename: string }) =>
27+
file.status == "modified" || file.status == "added",
28+
)
29+
.map((file: { filename: string }) => file.filename)
30+
.forEach((filename: string) => allFiles.push(filename));
31+
}
2232

23-
files
24-
.filter(
25-
(file: { status: string; filename: string }) =>
26-
file.status == "modified" || file.status == "added",
27-
)
28-
.map((file: { filename: string }) => file.filename)
29-
.forEach((filename: string) => allFiles.push(filename));
30-
}
31-
32-
return allFiles;
33+
return allFiles;
3334
}

0 commit comments

Comments
 (0)