mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
added validation of environment variable names
This commit is contained in:
parent
1f1c63dc7a
commit
ca41f63c48
@ -86,6 +86,12 @@ class AwsCompileFunctions {
|
||||
this.serverless.service.provider.environment,
|
||||
functionObject.environment
|
||||
)
|
||||
|
||||
for(var key in newFunction.Properties.Environment.Variables){
|
||||
// I pulled this from the bash man pages
|
||||
if(!key.match(/^[A-Za-z_][a-zA-Z0-9_]*$/)){
|
||||
throw new Error("Invalid characters in environment variable");
|
||||
}
|
||||
}
|
||||
|
||||
if ('role' in functionObject) {
|
||||
|
||||
@ -420,6 +420,22 @@ describe('AwsCompileFunctions', () => {
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
it('should throw if invalid environment variable name', () => {
|
||||
awsCompileFunctions.serverless.service.functions = {
|
||||
func: {
|
||||
handler: 'func.function.handler',
|
||||
name: 'new-service-dev-func',
|
||||
environment: {
|
||||
'1test1': 'test1',
|
||||
test2: 'test2',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(() => awsCompileFunctions.compileFunctions()).to.throw(Error);
|
||||
});
|
||||
|
||||
it('should consider function based config when creating a function resource', () => {
|
||||
awsCompileFunctions.serverless.service.functions = {
|
||||
func: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user