Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
fix: cidr port range check (#829)
Browse files Browse the repository at this point in the history
* fix: only allow cidr updates for ports 0-65535
  • Loading branch information
SanketD92 authored Dec 8, 2021
1 parent 7506895 commit dbfa431
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,48 @@ describe('EnvironmentScCidrService', () => {
}
});

it('should not call anything since request has invalid port numbers', async () => {
// BUILD
const requestContext = {};
let params = {
id: 'testId',
updateRequest: [
{
protocol: 'tcp',
fromPort: 65536,
toPort: 65536,
cidrBlocks: ['123.123.123.123/32'],
},
],
};
// OPERATE
try {
await service.update(requestContext, params);
expect.hasAssertions();
} catch (err) {
expect(err.message).toEqual('Input has validation errors');
}

params = {
id: 'testId',
updateRequest: [
{
protocol: 'tcp',
fromPort: -10,
toPort: -10,
cidrBlocks: ['123.123.123.123/32'],
},
],
};
// OPERATE
try {
await service.update(requestContext, params);
expect.hasAssertions();
} catch (err) {
expect(err.message).toEqual('Input has validation errors');
}
});

it('should throw the exception as expected during internal errors for revoke', async () => {
// BUILD
const requestContext = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
"type": "object",
"properties": {
"fromPort": {
"type": "integer"
"type": "integer",
"minimum": 0,
"maximum": 65535
},
"toPort": {
"type": "integer"
"type": "integer",
"minimum": 0,
"maximum": 65535
},
"protocol": {
"type": "string"
Expand Down

0 comments on commit dbfa431

Please sign in to comment.