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
3 changes: 2 additions & 1 deletion apps/api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ SECURITY_HUB_ROLE_ASSUMER_ARN=
SECURITY_HUB_GOVCLOUD_ROLE_ASSUMER_ARN=
SECURITY_HUB_GOVCLOUD_ACCESS_KEY_ID=
SECURITY_HUB_GOVCLOUD_SECRET_ACCESS_KEY=
SECURITY_HUB_GOVCLOUD_SESSION_TOKEN=
# Optional: only set when using temporary GovCloud credentials. Leave unset for long-lived IAM user keys.
# SECURITY_HUB_GOVCLOUD_SESSION_TOKEN=
3 changes: 1 addition & 2 deletions apps/api/src/cloud-security/aws-partition.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ describe('aws partition utils', () => {
it('uses explicit GovCloud base credentials when configured', () => {
process.env.SECURITY_HUB_GOVCLOUD_ACCESS_KEY_ID = 'AKIAGOV';
process.env.SECURITY_HUB_GOVCLOUD_SECRET_ACCESS_KEY = 'secret';
process.env.SECURITY_HUB_GOVCLOUD_SESSION_TOKEN = 'token';
process.env.SECURITY_HUB_GOVCLOUD_SESSION_TOKEN = 'placeholder';

expect(getAwsBaseCredentials('aws-us-gov')).toEqual({
accessKeyId: 'AKIAGOV',
secretAccessKey: 'secret',
sessionToken: 'token',
});
expect(getAwsBaseCredentials('aws')).toBeUndefined();

Expand Down
1 change: 0 additions & 1 deletion apps/api/src/cloud-security/aws-partition.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export function getAwsBaseCredentials(
return {
accessKeyId,
secretAccessKey,
sessionToken: process.env.SECURITY_HUB_GOVCLOUD_SESSION_TOKEN,
};
}

Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/evidence-forms/evidence-forms.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,16 @@ export class EvidenceFormsService {
);
}

const base64Pattern = /^[A-Za-z0-9+/]+={0,2}$/;
if (!base64Pattern.test(normalized)) {
const fileBuffer = Buffer.from(normalized, 'base64');

if (fileBuffer.toString('base64') !== normalized) {
throw new BadRequestException(
'Invalid file data. Expected base64 string.',
);
}

const fileBuffer = Buffer.from(normalized, 'base64');
if (!fileBuffer.length) {
throw new BadRequestException('File cannot be empty');
throw new BadRequestException('File cannot be empty.');
}

return fileBuffer;
Expand Down
Loading