Skip to content

Commit

Permalink
fix: windows support requires absolute path to manifest
Browse files Browse the repository at this point in the history
Signed-off-by: Ilona Shishov <[email protected]>
  • Loading branch information
IlonaShishov committed Jul 15, 2024
1 parent 7ac4384 commit 496b01d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scan_npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ 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 }}
Expand Down
10 changes: 6 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138077,6 +138077,7 @@ const vulnerabilitySeverityOrder = {




/**
* Resolves the manifest file path and its corresponding ecosystem.
* @returns A promise that resolves to an object containing the manifest file path and ecosystem.
Expand All @@ -138088,7 +138089,7 @@ 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,10 +138099,11 @@ 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);
core.info(`manifestDir: ${manifestDir}, manifestFilename: ${manifestFilename}`);
const resolvedManifestPath = getOS() === 'windows' ? `${manifestDir}\\${manifestFilename}` : `${manifestDir}/${manifestFilename}`;
core.info(`ℹ️ Manifest file path is "${resolvedManifestPath}"`);
return {
manifestFilePath: resolvedManifestPath,
Expand Down Expand Up @@ -140934,7 +140936,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 @@ -141103,6 +141104,7 @@ function getDependencyAnalysisConfig() {
* @returns A promise that resolves to an object containing the RHDA report JSON and file path.
*/
async function generateRHDAReport(manifestFilePath, ecosystem) {
core.info(`pathToManifest: ${manifestFilePath}`);
core.info(`⏳ Analysing dependencies...`);
let rhdaReportJson;
if (ecosystem === DOCKER) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

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
1 change: 0 additions & 1 deletion src/exhortServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 3 additions & 6 deletions src/manifestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import path from 'path';
import { promises as fs } from 'fs';

import { Inputs } from './generated/inputs-outputs.js';
import {
fileNameToEcosystemMappings,
DEFAULT_MANIFEST_DIR,
} from './constants.js';
import { fileNameToEcosystemMappings } from './constants.js';

/**
* Resolves the manifest file path and its corresponding ecosystem.
Expand All @@ -25,7 +22,7 @@ export async function resolveManifestFilePath(): Promise<{
`"${Inputs.MANIFEST_DIRECTORY}" not provided. Using working directory "${process.cwd()}"`,
);
}
const manifestDir = manifestDirInput || DEFAULT_MANIFEST_DIR;
const manifestDir = manifestDirInput ? path.resolve(manifestDirInput) : process.cwd();

Check failure on line 25 in src/manifestHandler.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Replace `·?·path.resolve(manifestDirInput)` with `⏎········?·path.resolve(manifestDirInput)⏎·······`

let manifestFilename: string;
if (manifestFileInput) {
Expand All @@ -39,7 +36,7 @@ export async function resolveManifestFilePath(): Promise<{
`"${Inputs.MANIFEST_FILE}" input not provided. Auto-detecting manifest file`,
);
ghCore.info(

Check failure on line 38 in src/manifestHandler.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Replace `⏎············`🔍·Looking·for·manifest·in·"${manifestDir}"...`,⏎········` with ``🔍·Looking·for·manifest·in·"${manifestDir}"...``
`🔍 Looking for manifest in "${path.join(process.cwd(), manifestDir)}"...`,
`🔍 Looking for manifest in "${manifestDir}"...`,
);

manifestFilename = await autoDetectManifest(manifestDir);
Expand Down
1 change: 1 addition & 0 deletions src/rhda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function generateRHDAReport(
manifestFilePath: string,
ecosystem: string,
): Promise<{ rhdaReportJson: any; rhdaReportJsonFilePath: string }> {
ghCore.info(`pathToManifest: ${manifestFilePath}`);
ghCore.info(`⏳ Analysing dependencies...`);

let rhdaReportJson: string | any;
Expand Down

0 comments on commit 496b01d

Please sign in to comment.