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 631fb6e
Show file tree
Hide file tree
Showing 23 changed files with 137 additions and 88 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
13 changes: 8 additions & 5 deletions .github/workflows/scan_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
- index: 2
manifest_file: ""
runs-on: ${{ matrix.os }}
env:
ACTIONS_RUNNER_DEBUG: true
EXHORT_DEBUG: 'true'
defaults:
run:
shell: bash
Expand All @@ -42,20 +45,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 }}
19 changes: 14 additions & 5 deletions .github/workflows/scan_go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,32 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Convert LF to CRLF in manifest file
if: matrix.os == 'windows-latest'
run: |
awk -i inplace '{printf "%s\r\n", $0}' manifests/golang/go.mod
cat -v manifests/golang/go.mod
shell: bash

- 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
19 changes: 9 additions & 10 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 @@ -140914,6 +140913,7 @@ function imageAnalysisService(images, options) {
properties += ` -D${setting}=${options[setting]}`;
}
}
console.log(`java${properties} -jar ${jarPath} ${reportType}${parameters}`);
try {
const result = (0,external_child_process_.execSync)(`java${properties} -jar ${jarPath} ${reportType}${parameters}`, {
maxBuffer: 1000 * 1000 * 10, // 10 MB
Expand All @@ -140934,7 +140934,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 +141110,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 +141305,7 @@ function fetchResult(ruleId, textMessage, manifestFilePath, startLine) {
text: textMessage,
};
const artifactLocation = {
uri: manifestFilePath.split((external_path_default()).sep).join((external_path_default()).posix.sep),
uri: 'file:///' + manifestFilePath.split((external_path_default()).sep).join((external_path_default()).posix.sep),
};
const region = {
startLine: startLine,
Expand Down Expand Up @@ -141787,7 +141786,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.

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
)
3 changes: 0 additions & 3 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ export const SARIF_SCHEMA_URL =
// Version of the SARIF schema.
export const SARIF_SCHEMA_VERSION = '2.1.0';

// Default directory to look for manifest files.
export const DEFAULT_MANIFEST_DIR = '.';

// Supported manifests and files
const GO_MOD = 'go.mod';
const POM_XML = 'pom.xml';
Expand Down
3 changes: 1 addition & 2 deletions src/exhortServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function imageAnalysisService(
properties += ` -D${setting}=${options[setting]}`;
}
}

console.log(`java${properties} -jar ${jarPath} ${reportType}${parameters}`)

Check failure on line 35 in src/exhortServices.ts

View workflow job for this annotation

GitHub Actions / Lint and Test

Replace ``java${properties}·-jar·${jarPath}·${reportType}${parameters}`)` with `⏎············`java${properties}·-jar·${jarPath}·${reportType}${parameters}`,⏎········);`

Check failure on line 35 in src/exhortServices.ts

View workflow job for this annotation

GitHub Actions / Lint and Test

Missing semicolon
try {
const result = execSync(
`java${properties} -jar ${jarPath} ${reportType}${parameters}`,
Expand All @@ -59,7 +59,6 @@ async function stackAnalysisService(
): Promise<string | exhort.AnalysisReport> {
try {
// Get stack analysis in JSON format
console.log(`pathToManifest: ${pathToManifest}`)
const stackAnalysisReportJson = await exhort.stackAnalysis(
pathToManifest,
false,
Expand Down
Loading

0 comments on commit 631fb6e

Please sign in to comment.