-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sanitizes AWS resource names in deploylib and related IAC files
- Loading branch information
1 parent
305d164
commit 1ac3365
Showing
29 changed files
with
1,089 additions
and
113 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { regexpMatch } from '../sanitizer' | ||
|
||
export const service = { | ||
nameValidation() { | ||
return { | ||
minLength: 4, | ||
maxLength: 40, | ||
rules: [regexpMatch('', /^[\w-]+$/, (n) => n.replace(/[^\w-]/g, '-'))], | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { regexpMatch } from '../sanitizer' | ||
|
||
export const logGroup = { | ||
nameValidation() { | ||
return { | ||
minLength: 1, | ||
maxLength: 512, | ||
rules: [ | ||
regexpMatch( | ||
"Log group names consist of the following characters: a-z, A-Z, 0-9, '_' (underscore), '-' (hyphen), '/' (forward slash), '.' (period), and '#' (number sign).", | ||
/^[-._/#A-Za-z\d]+$/, | ||
(n) => n.replace(/[^-._/#A-Za-z\d]/g, '_') | ||
), | ||
], | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { regexpMatch } from '../sanitizer' | ||
|
||
export const tag = { | ||
keyValidation() { | ||
return { | ||
minLength: 1, | ||
maxLength: 128, | ||
rules: [ | ||
regexpMatch('', /^[\p{L}\p{Z}\p{N}_.:/=+\-@]+$/u, (n) => | ||
n.replace(/[^\p{L}\p{Z}\p{N}_.:/=+\-@]/gu, '_') | ||
), | ||
], | ||
} | ||
}, | ||
|
||
valueValidation() { | ||
return { | ||
minLength: 0, | ||
maxLength: 256, | ||
rules: [ | ||
regexpMatch('', /^[\p{L}\p{Z}\p{N}_.:/=+\-@]+$/u, (n) => | ||
n.replace(/[^\p{L}\p{Z}\p{N}_.:/=+\-@]/gu, '_') | ||
), | ||
{ | ||
description: | ||
'The "aws:" prefix is prohibited for tags; it\'s reserved for AWS use.', | ||
apply: (v) => !v.startsWith('aws:'), | ||
fix: (v) => v.replace(/^aws:/, ''), | ||
}, | ||
], | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { regexpMatch } from '../sanitizer' | ||
|
||
export const table = { | ||
nameValidation() { | ||
return { | ||
minLength: 3, | ||
maxLength: 255, | ||
rules: [ | ||
regexpMatch('', /^[a-zA-Z0-9_.-]+$/, (n) => n.replace(/[^a-zA-Z0-9_.-]/g, '_')), | ||
], | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { regexpMatch } from '../sanitizer' | ||
|
||
export const vpc = { | ||
securityGroup: { | ||
nameValidation() { | ||
return { | ||
minLength: 1, | ||
maxLength: 255, | ||
rules: [ | ||
regexpMatch( | ||
'a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$*', | ||
/^[\w -.:/()#,@\[\]+=&;{}!$*]+$/, | ||
(s) => s.replace(/[^\w -.:/()#,@\[\]+=&;{}!$*]/g, '_') | ||
), | ||
], | ||
} | ||
}, | ||
}, | ||
} | ||
|
||
export const classic = { | ||
securityGroup: { | ||
nameValidation() { | ||
return { | ||
minLength: 1, | ||
maxLength: 255, | ||
rules: [ | ||
regexpMatch('Must only containASCII characters', /^[[:ascii:]]+$/, (s) => | ||
s.replace(/[^[:ascii:]]/g, '_') | ||
), | ||
{ | ||
description: "Cannot start with 'sg-'", | ||
validate: (s) => !s.startsWith('sg-'), | ||
fix: (s) => s.substring(3), | ||
}, | ||
], | ||
} | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { regexpMatch } from '../sanitizer' | ||
|
||
export const cluster = { | ||
nameValidation() { | ||
return { | ||
minLength: 1, | ||
maxLength: 255, | ||
rules: [regexpMatch('', /^[\w-]+$/, (s) => s.replace(/[^\w-]/g, '_'))], | ||
} | ||
}, | ||
} | ||
|
||
export const taskDefinition = { | ||
familyValidation() { | ||
return { | ||
minLength: 1, | ||
maxLength: 255, | ||
rules: [regexpMatch('', /^[\w-]+$/, (s) => s.replace(/[^\w-]/g, '_'))], | ||
} | ||
}, | ||
} | ||
|
||
export const service = { | ||
nameValidation() { | ||
return { | ||
minLength: 1, | ||
maxLength: 255, | ||
rules: [regexpMatch('', /^[\w-]+$/, (s) => s.replace(/[^\w-]/g, '_'))], | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { regexpMatch } from '../sanitizer' | ||
|
||
export const cluster = { | ||
nameValidation() { | ||
return { | ||
minLength: 1, | ||
maxLength: 100, | ||
rules: [ | ||
regexpMatch( | ||
'The name can contain only alphanumeric characters (case-sensitive) and hyphens.', | ||
/^[a-zA-Z\d-]+$/, | ||
(s) => s.replace(/[^a-zA-Z\d-]/g, '_') | ||
), | ||
regexpMatch('The name must start with an alphabetic character', /^[a-zA-Z]/, (s) => | ||
s.replace(/^[^a-zA-Z]+/, '') | ||
), | ||
], | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { regexpMatch, regexpNotMatch } from '../sanitizer' | ||
|
||
export const cacheCluster = { | ||
cacheClusterIdValidation() { | ||
return { | ||
minLength: 1, | ||
maxLength: 50, | ||
rules: [ | ||
regexpMatch('', /[a-zA-Z0-9-]/, (s) => s.replace(/[^a-zA-Z0-9-]/g, '-')), | ||
{ | ||
description: 'Identifier must not end with a hyphen', | ||
validate: (s) => !s.endsWith('-'), | ||
fix: (s) => s.replace(/-+$/, ''), | ||
}, | ||
regexpNotMatch('Identifier must not contain consecutive hyphens', /--/, (s) => | ||
s.replace(/--+/g, '-') | ||
), | ||
regexpMatch('Identifier must start with a letter', /^[a-zA-Z]/, (s) => | ||
s.replace(/^[^a-zA-Z]+/, '') | ||
), | ||
], | ||
} | ||
}, | ||
} | ||
export const cacheSubnetGroup = { | ||
cacheSubnetGroupNameValidation() { | ||
return { | ||
minLength: 1, | ||
maxLength: 255, | ||
rules: [ | ||
regexpMatch( | ||
'', | ||
/^[a-z\d-]+$/, // uppercase is technically valid, but AWS will convert the value to lowercase | ||
(s) => s.toLocaleLowerCase().replace(/[^a-z\d-]/g, '-') | ||
), | ||
{ | ||
description: 'Identifier must not end with a hyphen', | ||
validate: (s) => !s.endsWith('-'), | ||
fix: (s) => s.replace(/-+$/, ''), | ||
}, | ||
regexpNotMatch('Identifier must not contain consecutive hyphens', /--/, (s) => | ||
s.replace(/--+/g, '-') | ||
), | ||
regexpMatch('Identifier must start with a letter', /^[a-zA-Z]/, (s) => | ||
s.replace(/^[^a-zA-Z]+/, '') | ||
), | ||
], | ||
} | ||
}, | ||
} |
Oops, something went wrong.