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 81041cc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
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.

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
10 changes: 7 additions & 3 deletions src/manifestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
fileNameToEcosystemMappings,
DEFAULT_MANIFEST_DIR,

Check failure on line 8 in src/manifestHandler.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

'DEFAULT_MANIFEST_DIR' is defined but never used
} from './constants.js';
import { getOS } from './utils.js';

/**
* Resolves the manifest file path and its corresponding ecosystem.
Expand All @@ -25,7 +26,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 29 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,13 +40,16 @@ export async function resolveManifestFilePath(): Promise<{
`"${Inputs.MANIFEST_FILE}" input not provided. Auto-detecting manifest file`,
);
ghCore.info(

Check failure on line 42 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);
}

const resolvedManifestPath = path.join(manifestDir, manifestFilename);
ghCore.info(
`manifestDir: ${manifestDir}, manifestFilename: ${manifestFilename}`,
);
const resolvedManifestPath = getOS() === 'windows' ? `${manifestDir}\\${manifestFilename}` : `${manifestDir}/${manifestFilename}`

Check failure on line 52 in src/manifestHandler.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Replace `·getOS()·===·'windows'·?·`${manifestDir}\\${manifestFilename}`·:·`${manifestDir}/${manifestFilename}`` with `⏎········getOS()·===·'windows'⏎············?·`${manifestDir}\\${manifestFilename}`⏎············:·`${manifestDir}/${manifestFilename}`;`

Check failure on line 52 in src/manifestHandler.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Missing semicolon
ghCore.info(`ℹ️ Manifest file path is "${resolvedManifestPath}"`);

return {
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 81041cc

Please sign in to comment.