Skip to content

Commit

Permalink
fix: stack status event validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Jul 9, 2018
1 parent aae6af2 commit a354739
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/in-house-bot/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ export class Deployment {
}

public getChildDeploymentWithProps = async (props={}): Promise<IDeploymentConf> => {
assertNoNullProps(props, `invalid filter props: ${JSON.stringify(props)}`)

return this.getChildDeployment({
filter: {
EQ: props
Expand Down Expand Up @@ -1160,3 +1162,11 @@ const getTmpSNSTopicName = ({ id, type }: {
const genSID = (base: string) => `${base}${randomStringWithLength(10)}`

const getTmpTopicExpirationDate = () => Date.now() + TMP_SNS_TOPIC_TTL

const assertNoNullProps = (obj: any, msg: string) => {
for (let p in obj) {
if (obj[p] == null) {
throw new Errors.InvalidInput(msg)
}
}
}
16 changes: 11 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1479,12 +1479,18 @@ export const parseStackStatusEvent = (event: any): StackStatus => {
return map
}, {})

const { StackId, Timestamp, ResourceStatus, ResourceType } = props
const subscriptionArn = event.Records[0].EventSubscriptionArn
if (!(StackId && Timestamp && ResourceStatus && ResourceType && subscriptionArn)) {
throw new Errors.InvalidInput('invalid stack status event')
}

return {
stackId: props.StackId,
timestamp: new Date(props.Timestamp).getTime(),
status: props.ResourceStatus,
resourceType: props.ResourceType,
subscriptionArn: event.Records[0].EventSubscriptionArn,
stackId: StackId,
timestamp: new Date(Timestamp).getTime(),
status: ResourceStatus,
resourceType: ResourceType,
subscriptionArn,
}
}

Expand Down

0 comments on commit a354739

Please sign in to comment.