Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error log #73

Merged
merged 5 commits into from
May 10, 2024
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
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 @@ -33,11 +33,11 @@

for await (const { data: page } of iterator) {
for (const user of page) {
if (user.permissions!.admin) {

Check warning on line 36 in src/identitiesInRepo/identitiesInRepoService.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
numberOfAdmins++;
} else if (user.permissions!.maintain!) {

Check warning on line 38 in src/identitiesInRepo/identitiesInRepoService.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion

Check warning on line 38 in src/identitiesInRepo/identitiesInRepoService.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
numberOfWriters++;
} else if (user.permissions!.push!) {

Check warning on line 40 in src/identitiesInRepo/identitiesInRepoService.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
numberOfWriters++;
} else if (user.permissions!.triage!) {
numberOfReaders++;
Expand All @@ -56,7 +56,7 @@
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
Loading