Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions lib/evidence-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function collectEvidences() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
try {
core.startGroup('Collecting evidences');
core.startGroup('Collecting evidence');
// Check authentication method first - evidence collection requires access token or OIDC
const credentials = utils_1.Utils.collectJfrogCredentialsFromEnvVars();
if (!credentials.accessToken && !credentials.oidcProviderName && (credentials.username || credentials.password)) {
Expand All @@ -62,7 +62,6 @@ function collectEvidences() {
// Check if evidence collection is supported by the server
const evidenceConfig = yield getEvidenceConfiguration();
if (!evidenceConfig.external_evidence_collection_supported) {
core.info("Evidence collection is not supported by Artifactory's license type. Skipping evidence collection.");
return;
}
// Use a default limit if the server doesn't provide one
Expand Down Expand Up @@ -116,19 +115,30 @@ function getEvidenceConfiguration() {
}
catch (error) {
core.warning(`Failed to get evidence configuration (network error or server unavailable): ${error}`);
return {external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0};
return { external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0 };
}
// 200 OK
if (response.message.statusCode !== 200) {
core.warning(`Failed to get evidence configuration. Status: ${response.message.statusCode}, Response: ${body}`);
return {external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0};
// 401 Unauthorized
if (response.message.statusCode === 401) {
core.warning(`Failed to get evidence configuration. Given credentials are not sufficient` +
` to create evidence in the JFrog platform, Response: ${body}`);
}
else {
core.warning(`Failed to get evidence configuration. Status: ${response.message.statusCode}, Response: ${body}`);
}
return { external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0 };
}
try {
const config = JSON.parse(body);
if (!config.external_evidence_collection_supported) {
core.info("Evidence collection is not supported by Artifactory's license type. Skipping evidence collection.");
}
return config;
}
catch (error) {
core.warning(`Failed to parse evidence config response: ${error}`);
return {external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0};
return { external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0 };
}
});
}
Expand Down Expand Up @@ -161,10 +171,14 @@ function getSigstoreBundlePaths() {
return [];
}
core.info(`Found ${filePaths.length} sigstore bundle file(s) to process.`);
if (core.isDebug()) {
filePaths.forEach((filePath) => {
core.debug(`Sigstore bundle file found: ${filePath}`);
});
}
return filePaths;
});
}

/**
* Creates evidence for sigstore bundle files.
* @param maxFileSizeMB Maximum allowed file size in MB
Expand Down
4 changes: 4 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ class Utils {
}
static setCliEnv() {
var _a, _b, _c, _d, _e;
if (core.isDebug()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can add another check that JFROG_CLI_LOG_LEVEL was not already configured by the user.
if for some case user put JFROG_CLI_LOG_LEVEL=ERROR in his environment we need to respect that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using the exportVariableIfNotSet() that does that. We don't override user explicit environment variables

Utils.exportVariableIfNotSet('JFROG_CLI_LOG_LEVEL', 'DEBUG');
}
Utils.exportVariableIfNotSet('JFROG_CLI_ENV_EXCLUDE', '*password*;*secret*;*key*;*token*;*auth*;JF_ARTIFACTORY_*;JF_ENV_*;JF_URL;JF_USER;JF_PASSWORD;JF_ACCESS_TOKEN');
Utils.exportVariableIfNotSet('JFROG_CLI_OFFER_CONFIG', 'false');
Utils.exportVariableIfNotSet('CI', 'true');
Expand Down Expand Up @@ -377,6 +380,7 @@ class Utils {
*/
static runCliAndGetOutput(args, options) {
return __awaiter(this, void 0, void 0, function* () {
core.debug(`jf ${args.join(' ')}`);
let output;
output = yield (0, exec_1.getExecOutput)('jf', args, Object.assign(Object.assign({}, options), { ignoreReturnCode: true }));
if (output.exitCode !== core.ExitCode.Success) {
Expand Down
23 changes: 20 additions & 3 deletions src/evidence-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface EvidenceConfigResponse {
*/
export async function collectEvidences() {
try {
core.startGroup('Collecting evidences');
core.startGroup('Collecting evidence');

// Check authentication method first - evidence collection requires access token or OIDC
const credentials = Utils.collectJfrogCredentialsFromEnvVars();
Expand All @@ -35,7 +35,6 @@ export async function collectEvidences() {
// Check if evidence collection is supported by the server
const evidenceConfig = await getEvidenceConfiguration();
if (!evidenceConfig.external_evidence_collection_supported) {
core.info("Evidence collection is not supported by Artifactory's license type. Skipping evidence collection.");
return;
}

Expand Down Expand Up @@ -96,13 +95,26 @@ async function getEvidenceConfiguration(): Promise<EvidenceConfigResponse> {
return { external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0 };
}

// 200 OK
if (response.message.statusCode !== 200) {
core.warning(`Failed to get evidence configuration. Status: ${response.message.statusCode}, Response: ${body}`);
// 401 Unauthorized
if (response.message.statusCode === 401) {
core.warning(
`Failed to get evidence configuration. Given credentials are not sufficient` +
` to create evidence in the JFrog platform, Response: ${body}`,
);
} else {
core.warning(`Failed to get evidence configuration. Status: ${response.message.statusCode}, Response: ${body}`);
}

return { external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0 };
}

try {
const config: EvidenceConfigResponse = JSON.parse(body);
if (!config.external_evidence_collection_supported) {
core.info("Evidence collection is not supported by Artifactory's license type. Skipping evidence collection.");
}
return config;
} catch (error) {
core.warning(`Failed to parse evidence config response: ${error}`);
Expand Down Expand Up @@ -142,6 +154,11 @@ export async function getSigstoreBundlePaths(): Promise<string[]> {
}

core.info(`Found ${filePaths.length} sigstore bundle file(s) to process.`);
if (core.isDebug()) {
filePaths.forEach((filePath) => {
core.debug(`Sigstore bundle file found: ${filePath}`);
});
}
return filePaths;
}

Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ export class Utils {
}

public static setCliEnv() {
if (core.isDebug()) {
Utils.exportVariableIfNotSet('JFROG_CLI_LOG_LEVEL', 'DEBUG');
}
Utils.exportVariableIfNotSet(
'JFROG_CLI_ENV_EXCLUDE',
'*password*;*secret*;*key*;*token*;*auth*;JF_ARTIFACTORY_*;JF_ENV_*;JF_URL;JF_USER;JF_PASSWORD;JF_ACCESS_TOKEN',
Expand Down Expand Up @@ -418,6 +421,7 @@ export class Utils {
* @throws An error if the JFrog CLI command exits with a non-success code.
*/
public static async runCliAndGetOutput(args: string[], options?: ExecOptions): Promise<string> {
core.debug(`jf ${args.join(' ')}`);
let output: ExecOutput;
output = await getExecOutput('jf', args, { ...options, ignoreReturnCode: true });
if (output.exitCode !== core.ExitCode.Success) {
Expand Down
Loading