Skip to content

Commit

Permalink
Logs look good
Browse files Browse the repository at this point in the history
  • Loading branch information
hampus-andersson-op committed Apr 18, 2024
1 parent 8035999 commit 8edd7ca
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
18 changes: 5 additions & 13 deletions src/branchprotection/BranchProtectionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@ export class BranchProtectionService {

const octokit: InstanceType<typeof GitHub> = github.getOctokit(token);
type branchProtectionRepsponse = Endpoints['GET /repos/{owner}/{repo}/branches/{branch}/protection']['response'];
const response: branchProtectionRepsponse | any = await octokit.rest.repos
.getBranchProtection({
owner,
repo,
branch: 'main',
})
.catch((x: RequestError) => {
core.info(JSON.stringify(x));
return {};
});
const response: branchProtectionRepsponse | any = await octokit.rest.repos.getBranchProtection({

Check warning on line 14 in src/branchprotection/BranchProtectionService.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
owner,
repo,
branch: 'main',
});

if (response.data.enforce_admins?.enabled === false) {
core.warning('Branch protection can be overridden by admins and is therefore counted as not enabled');
Expand All @@ -44,9 +39,6 @@ export class BranchProtectionService {
title: 'Branch protection control failed',
});
} else if (error.status === 404) {
core.info(error.status);
core.info(error.errors);

// Status code '404' means 'Branch not protected'
core.notice('Branch protection is not enabled for this repository or credentials lack permissions', {
title: 'Branch protection control',
Expand Down
14 changes: 9 additions & 5 deletions src/sasttools/CodeQLService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ export class CodeQLService {
core.exportVariable('SASTnumberOfSeverity3', sastNumberOfSeverity3);
core.exportVariable('SASTnumberOfSeverity4', sastNumberOfSeverity4);
} catch (error) {
core.info(error.status);

core.info('Failed to get CodeQL severities');
core.warning(error.message, {
title: 'SAST tool control failed',
});
if (error.status === 401 || error.status === 403 || error.status === 404) {
core.warning(error.message, {
title: 'SAST tool control failed',
});
} else {
core.notice(error.message, {
title: 'SAST tool control failed',
});
}
core.exportVariable('SASTnumberOfSeverity1', 0);
core.exportVariable('SASTnumberOfSeverity2', 0);
core.exportVariable('SASTnumberOfSeverity3', 0);
Expand Down
14 changes: 9 additions & 5 deletions src/scatools/DependabotService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ export class DependabotService {
core.exportVariable('SCAnumberOfSeverity3', scaNumberOfSeverity3);
core.exportVariable('SCAnumberOfSeverity4', scaNumberOfSeverity4);
} catch (error) {
core.info(error.status);

core.info('Failed to get Dependabot severities');
core.warning(error.message, {
title: 'SCA tool control failed',
});
if (error.status === 401 || error.status === 403 || error.status === 404) {
core.warning(error.message, {
title: 'SCA tool control failed',
});
} else {
core.notice(error.message, {
title: 'SCA tool control failed',
});
}
core.exportVariable('SCAnumberOfSeverity1', 0);
core.exportVariable('SCAnumberOfSeverity2', 0);
core.exportVariable('SCAnumberOfSeverity3', 0);
Expand Down
1 change: 0 additions & 1 deletion src/secretscanning/SecretScanningService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class SecretScanningService {
console.log('Exposed secrets:', numberOfExposedSecrets);
core.exportVariable('numberOfExposedSecrets', numberOfExposedSecrets);
} catch (error) {
core.info(error.status);
core.info('Failed to get number of exposed secrets');
if (error.status === 401) {
core.warning(error.message, {
Expand Down

0 comments on commit 8edd7ca

Please sign in to comment.