Skip to content

Commit

Permalink
fix: windows support
Browse files Browse the repository at this point in the history
Signed-off-by: Ilona Shishov <[email protected]>
  • Loading branch information
IlonaShishov committed Jul 16, 2024
1 parent 7ac4384 commit 90cece4
Show file tree
Hide file tree
Showing 25 changed files with 119 additions and 94 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
pull_request:

jobs:
lint:
name: Run ESLint
lint-and-test:
name: Lint and Test
runs-on: ubuntu-latest

steps:
Expand All @@ -25,6 +25,9 @@ jobs:

- name: Run lint
run: npm run lint

- name: Run test
run: npm run test

check-dist:
name: Check Distribution
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/scan_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

- name: Install syft
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
curl -sSfL https://raw.githubusercontent.com/anchore/syft/v1.7.0/install.sh | sh -s -- -b /usr/local/bin
- name: Install skopeo
run: |
Expand All @@ -42,20 +42,20 @@ jobs:
- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@main
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/docker
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_json }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_sarif }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
12 changes: 7 additions & 5 deletions .github/workflows/scan_go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@ jobs:

- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@main
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/golang
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_json }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}
shell: bash

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_sarif }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}
shell: bash

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
19 changes: 14 additions & 5 deletions .github/workflows/scan_gradle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,31 @@ jobs:
distribution: temurin
java-version: '20'

- name: Install gradle dependencies
if: matrix.os == 'windows-latest'
run: |
cd manifests/gradle/
gradle dependencies
cd ../../
- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@main
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/gradle
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_json }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}
shell: bash

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_sarif }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}
shell: bash

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
12 changes: 7 additions & 5 deletions .github/workflows/scan_maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,22 @@ jobs:

- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@main
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/maven
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_json }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}
shell: bash

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_sarif }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}
shell: bash

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
12 changes: 7 additions & 5 deletions .github/workflows/scan_npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@ jobs:

- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@main
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/npm
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_json }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}
shell: bash

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_sarif }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}
shell: bash

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
12 changes: 7 additions & 5 deletions .github/workflows/scan_podman.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,22 @@ jobs:
- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@main
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/podman
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_json }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}
shell: bash

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_sarif }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}
shell: bash

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
12 changes: 7 additions & 5 deletions .github/workflows/scan_python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,22 @@ jobs:

- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@main
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/python
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_json }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}
shell: bash

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.crda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.crda_report_sarif }}
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}
shell: bash

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![Scan Podman project](https://github.com/RHEcosystemAppEng/rhda-github-action/actions/workflows/scan_podman.yaml/badge.svg)](https://github.com/RHEcosystemAppEng/rhda-github-action/actions/workflows/scan_podman.yaml)
<br>
<br>
<!-- [![tag badge](https://img.shields.io/github/v/tag/redhat-actions/crda)](https://github.com/redhat-actions/crda/tags) -->
[![tag badge](https://img.shields.io/github/v/tag/RHEcosystemAppEng/rhda-github-action)](https://github.com/RHEcosystemAppEng/rhda-github-action/tags)
[![license badge](https://img.shields.io/github/license/RHEcosystemAppEng/rhda-github-action)](./LICENSE)
[![size badge](https://img.shields.io/github/size/RHEcosystemAppEng/rhda-github-action/dist/index.js)](./dist)

Expand Down
34 changes: 19 additions & 15 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137975,7 +137975,6 @@ function escapeWindowsPathForActionsOutput(path) {
async function zipFile(file) {
const fileContents = await external_fs_.readFileSync(file, 'utf-8');
const zippedContents = (await external_zlib_.gzipSync(fileContents)).toString('base64');
// ghCore.info(`Zipped upload size: ${utils.convertToHumanFileSize(zippedContents.length)}`);
return zippedContents;
}
/**
Expand Down Expand Up @@ -138037,8 +138036,6 @@ const UTM_SOURCE = 'github-actions';
const SARIF_SCHEMA_URL = 'https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json';
// Version of the SARIF schema.
const SARIF_SCHEMA_VERSION = '2.1.0';
// Default directory to look for manifest files.
const DEFAULT_MANIFEST_DIR = '.';
// Supported manifests and files
const GO_MOD = 'go.mod';
const POM_XML = 'pom.xml';
Expand Down Expand Up @@ -138088,7 +138085,9 @@ async function resolveManifestFilePath() {
if (!manifestDirInput) {
core.info(`"${Inputs.MANIFEST_DIRECTORY}" not provided. Using working directory "${process.cwd()}"`);
}
const manifestDir = manifestDirInput || DEFAULT_MANIFEST_DIR;
const manifestDir = manifestDirInput
? external_path_default().resolve(manifestDirInput)
: process.cwd();
let manifestFilename;
if (manifestFileInput) {
manifestFilename = manifestFileInput;
Expand All @@ -138098,7 +138097,7 @@ async function resolveManifestFilePath() {
}
else {
core.info(`"${Inputs.MANIFEST_FILE}" input not provided. Auto-detecting manifest file`);
core.info(`🔍 Looking for manifest in "${external_path_default().join(process.cwd(), manifestDir)}"...`);
core.info(`🔍 Looking for manifest in "${manifestDir}"...`);
manifestFilename = await autoDetectManifest(manifestDir);
}
const resolvedManifestPath = external_path_default().join(manifestDir, manifestFilename);
Expand Down Expand Up @@ -138873,7 +138872,7 @@ function extractPackageName(line) {
*/
function getIgnoredDeps(manifest) {
let goMod = external_node_fs_.readFileSync(manifest).toString().trim();
let lines = goMod.split(external_os_.EOL);
let lines = goMod.split(getLineSeparatorGolang());
return lines.filter(line => ignoredLine(line)).map(line => extractPackageName(line)).map(dep => golang_gomodules_toPurl(dep, /[ ]{1,3}/, undefined));
}
/**
Expand Down Expand Up @@ -138947,7 +138946,7 @@ function collectAllDepsFromManifest(lines, goMod) {
*/
function performManifestVersionsCheck(rootElementName, goModGraphOutputRows, manifest) {
let goMod = external_node_fs_.readFileSync(manifest).toString().trim();
let lines = goMod.split(external_os_.EOL);
let lines = goMod.split(getLineSeparatorGolang());
let comparisonLines = goModGraphOutputRows.filter((line) => line.startsWith(rootElementName)).map((line) => getChildVertexFromEdge(line));
let manifestDeps = collectAllDepsFromManifest(lines, goMod);
try {
Expand Down Expand Up @@ -138997,7 +138996,7 @@ function golang_gomodules_getSBOM(manifest, opts = {}, includeTransitive) {
let ignoredDeps = getIgnoredDeps(manifest);
let allIgnoredDeps = ignoredDeps.map((dep) => dep.toString());
let sbom = new Sbom();
let rows = goGraphOutput.split(external_os_.EOL);
let rows = goGraphOutput.split(getLineSeparatorGolang());
let root = getParentVertexFromEdge(rows[0]);
let matchManifestVersions = getCustom("MATCH_MANIFEST_VERSIONS", "false", opts);
if (matchManifestVersions === "true") {
Expand Down Expand Up @@ -139085,7 +139084,7 @@ function getFinalPackagesVersionsForModule(rows, manifestPath, goBin) {
(0,external_node_child_process_namespaceObject.execSync)(`${handleSpacesInPath(goBin)} mod download`, options);
let finalVersionsForAllModules = (0,external_node_child_process_namespaceObject.execSync)(`${handleSpacesInPath(goBin)} list -m all`, options).toString();
let finalVersionModules = new Map();
finalVersionsForAllModules.split(external_os_.EOL).filter(string => string.trim() !== "")
finalVersionsForAllModules.split(getLineSeparatorGolang()).filter(string => string.trim() !== "")
.filter(string => string.trim().split(" ").length === 2)
.forEach((dependency) => {
let dep = dependency.split(" ");
Expand Down Expand Up @@ -139121,6 +139120,10 @@ function getFinalPackagesVersionsForModule(rows, manifestPath, goBin) {
function getPackageName(fullPackage) {
return fullPackage.split("@")[0];
}
function getLineSeparatorGolang() {
let reg = /\n|\r\n/;
return reg;
}
// /**
// *
// * @param {string} fullPackage - full package with its name and version-
Expand Down Expand Up @@ -140698,7 +140701,7 @@ async function requestComponent(provider, data, url, opts = {}, path = '') {
}
}
else {
throw new Error(`Got error response from exhort backend - http return code : ${resp.status}, error message => ${await resp.text()}`);
throw new Error(`Got error response from exhort backend - http return code : ${resp.status}, ex-request-id: ${resp.headers.get("ex-request-id")} error message => ${await resp.text()}`);
}
return Promise.resolve(result);
}
Expand Down Expand Up @@ -140934,7 +140937,6 @@ function imageAnalysisService(images, options) {
async function stackAnalysisService(pathToManifest, options) {
try {
// Get stack analysis in JSON format
console.log(`pathToManifest: ${pathToManifest}`);
const stackAnalysisReportJson = await src.stackAnalysis(pathToManifest, false, options);
return stackAnalysisReportJson;
}
Expand Down Expand Up @@ -141111,10 +141113,10 @@ async function generateRHDAReport(manifestFilePath, ecosystem) {
else {
rhdaReportJson = await stackAnalysisService(manifestFilePath, getDependencyAnalysisConfig());
}
const rhdaReportJsonFilePath = `${process.cwd()}/${core.getInput(Inputs.RHDA_REPORT_NAME)}.json`;
const rhdaReportJsonFilePath = `${process.cwd()}${getOS() === 'windows' ? '\\' : '/'}${core.getInput(Inputs.RHDA_REPORT_NAME)}.json`;
await writeToFile(JSON.stringify(rhdaReportJson, null, 4), rhdaReportJsonFilePath);
core.info(`✍️ Setting output "${Outputs.RHDA_REPORT_JSON}" to ${rhdaReportJsonFilePath}`);
core.setOutput(Outputs.RHDA_REPORT_JSON, rhdaReportJsonFilePath);
core.setOutput(Outputs.RHDA_REPORT_JSON, escapeWindowsPathForActionsOutput(rhdaReportJsonFilePath));
core.info(`✅ Successfully generated Red Had Dependency Analytics report`);
return {
rhdaReportJson: JSON.parse(JSON.stringify(rhdaReportJson)),
Expand Down Expand Up @@ -141306,7 +141308,9 @@ function fetchResult(ruleId, textMessage, manifestFilePath, startLine) {
text: textMessage,
};
const artifactLocation = {
uri: manifestFilePath.split((external_path_default()).sep).join((external_path_default()).posix.sep),
uri: external_path_default().relative(process.cwd(), manifestFilePath)
.split((external_path_default()).sep)
.join((external_path_default()).posix.sep),
};
const region = {
startLine: startLine,
Expand Down Expand Up @@ -141787,7 +141791,7 @@ async function waitForUploadToFinish(ghToken, sarifId) {
async function handleSarif(rhdaReportJson, manifestFilePath, ecosystem, sha, ref, analysisStartTime, prData) {
core.info(`⏳ Converting RHDA report JSON to SARIF...`);
const { sarifObject: rhdaReportSarif, vulSeverity: vulSeverity } = await generateSarif(rhdaReportJson, manifestFilePath, ecosystem);
const rhdaReportSarifFilePath = `${process.cwd()}/${core.getInput(Inputs.RHDA_REPORT_NAME)}.sarif`;
const rhdaReportSarifFilePath = `${process.cwd()}${getOS() === 'windows' ? '\\' : '/'}${core.getInput(Inputs.RHDA_REPORT_NAME)}.sarif`;
await writeToFile(JSON.stringify(rhdaReportSarif, null, 4), rhdaReportSarifFilePath);
core.info(`✅ Successfully converted RHDA report JSON to SARIF`);
core.info(`✍️ Setting output "${Outputs.RHDA_REPORT_SARIF}" to ${rhdaReportSarifFilePath}`);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Binary file added images/workflow_run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion manifests/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM --platform=linux/amd64 ubuntu:latest
FROM node:14
FROM python:3.9 AS python_stage
2 changes: 1 addition & 1 deletion manifests/golang/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ go 1.22

require (
golang.org/x/net v0.10.0 // indirect
aahframe.work v0.0.0-20160704040534-43507327c421
golang.org/x/net v0.0.0-20220802222814-0bcc04d9c69b
)
Loading

0 comments on commit 90cece4

Please sign in to comment.