-
Notifications
You must be signed in to change notification settings - Fork 40
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
Resource name sanitization #108
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
72c2b8d
Sanitizes AWS resource names in deploylib and related IAC files
DavidSeptimus 5a37027
Update pkg/infra/pulumi_aws/iac/sanitization/sanitizer.ts
DavidSeptimus c56a16c
rebase fixes
DavidSeptimus c87ee49
Adds reserved length for pulumi suffix
DavidSeptimus 70340c4
Fixes rds instance name double-hyphen rule
DavidSeptimus 2c43a1f
Fixes orm role name and lambda scheduler log group name
DavidSeptimus 7d4652f
adds quotes to message
DavidSeptimus be91a47
Adds back sanitization for ELB and Service Discovery post-rebase
DavidSeptimus ddf07cc
Revises addDir function in IAC plugin
DavidSeptimus 6560344
Fixes fix functions for tag keys and values
DavidSeptimus 9f35f12
Replacement pattern improvements for ELB
DavidSeptimus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, need to remove clustername as the actual name for this and memdb but lets maybe chat about that tomorrow