Skip to content

Commit

Permalink
Merge pull request #73 from Omegapoint/error-log
Browse files Browse the repository at this point in the history
Error log
  • Loading branch information
hampus-andersson-op authored May 10, 2024
2 parents 1b9d325 + fda4044 commit 5112d63
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/branchprotection/BranchProtectionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ export class BranchProtectionService {

core.exportVariable('numberOfReviewers', numberOfReviewers);
} catch (error) {
const errorMessage: string = error.message.split('-')[0].trim();
if (error.status === 401) {
core.info('Failed to get branch protection');
// Removes link to REST API endpoint
const errorMessage: string = error.message.split('-')[0];
core.warning(errorMessage, {
title: 'Branch protection control failed',
});
} else if (error.status === 404) {
if (error.message === 'Branch not protected') {
core.notice(error.message, {
if (errorMessage === 'Branch not protected') {
core.notice(errorMessage, {
title: 'Branch protection control',
});
core.exportVariable('numberOfReviewers', 0);
Expand All @@ -50,7 +50,7 @@ export class BranchProtectionService {
}
} else {
core.info('Failed to get branch protection');
core.notice(error.message, {
core.notice(errorMessage, {
title: 'Branch protection control failed',
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/identitiesInRepo/identitiesInRepoService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class IdentitiesInRepoService {
core.info('Failed to fetch identities for repo');
if (error.status === 401 || error.status === 403) {
// Removes link to REST API endpoint
const errorMessage: string = error.message.split('-')[0];
const errorMessage: string = error.message.split('-')[0].trim();
core.warning(errorMessage, {
title: 'Failed to fetch identities for repo',
});
Expand Down
2 changes: 1 addition & 1 deletion src/sasttools/CodeQLService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class CodeQLService {
core.info('Failed to get CodeQL severities');
if (error.status === 401 || error.status === 403 || error.status === 404) {
// Removes link to REST API endpoint
const errorMessage: string = error.message.split('-')[0];
const errorMessage: string = error.message.split('-')[0].trim();
core.warning(errorMessage, {
title: 'SAST tool control failed',
});
Expand Down
2 changes: 1 addition & 1 deletion src/scatools/DependabotService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class DependabotService {
core.info('Failed to get Dependabot severities');
if (error.status === 401 || error.status === 403 || error.status === 404) {
// Removes link to REST API endpoint
const errorMessage: string = error.message.split('-')[0];
const errorMessage: string = error.message.split('-')[0].trim();
core.warning(errorMessage, {
title: 'SCA tool control failed',
});
Expand Down
27 changes: 15 additions & 12 deletions src/secretscanning/SecretScanningService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,26 @@ export class SecretScanningService {
core.exportVariable('numberOfExposedSecrets', numberOfExposedSecrets);
} catch (error) {
core.info('Failed to get number of exposed secrets');
// Removes link to REST API endpoint
const errorMessage: string = error.message.split('-')[0].trim();
if (error.status === 401) {
// Removes link to REST API endpoint
const errorMessage: string = error.message.split('-')[0];
core.warning(errorMessage, {
title: 'Number of exposed secrets control failed',
});
} else if (error.status === 404) {
// Removes link to REST API endpoint
const errorMessage: string = error.message.split('-')[0];
if (errorMessage === 'Secret scanning is disabled on this repository') {
core.warning(errorMessage, {
title: 'Number of exposed secrets control failed',
});
} else {
core.warning('Credentials probably lack necessary permissions', {
title: 'Number of exposed secrets control failed',
});
switch (errorMessage) {
case 'Secret scanning is disabled on this repository.':
core.warning(errorMessage, {
title: 'Number of exposed secrets control failed',
});
break;

default:
console.log(error);
core.warning('Credentials probably lack necessary permissions', {
title: 'Number of exposed secrets control failed',
});
break;
}
} else {
core.notice(error.message, {
Expand Down

0 comments on commit 5112d63

Please sign in to comment.