Skip to content

Commit

Permalink
Merge pull request #9 from ECTwo/aws/cmd-injection
Browse files Browse the repository at this point in the history
Fix #5, Prevent command injection
  • Loading branch information
KimKiHyuk authored Oct 29, 2020
2 parents bf9b72f + 6070798 commit b542961
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ coverage

# Benchmarking
benchmarks/graphs

# IntelliJ
.idea/
*.iml
13 changes: 13 additions & 0 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ import AwsTerraformRouterV1 from './v1/terraform/Aws';
// Init router and path
const router = Router();

router.use((req, res, next) => {
const { access_key, secret_key } = req.headers;
if (typeof access_key === 'string' && !access_key.match(/^[A-Za-z0-9]+$/)) {
res.status(400).end(JSON.stringify({}));
return;
}
if (typeof secret_key === 'string' && !secret_key.match(/^[A-Za-z0-9]+$/)) {
res.status(400).end(JSON.stringify({}));
return;
}
next();
});

// Add sub-routes
router.use('/users', UserRouter);
router.use('/v1/aws', AwsRouterV1)
Expand Down

0 comments on commit b542961

Please sign in to comment.