-
Notifications
You must be signed in to change notification settings - Fork 5
Add snyk container scan workflow #147
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
base: main
Are you sure you want to change the base?
Changes from all commits
95d4ca2
b9b4929
f99b09a
628eb8c
b3dadb0
5eb016e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Snyk Container Scan | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| snyk-container-scan: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build Docker image | ||
| run: | | ||
| docker build -t my-app:ci . | ||
|
|
||
| - name: Run Snyk container scan | ||
| uses: snyk/actions/docker@v3 | ||
| with: | ||
| image: my-app:ci | ||
| args: --file=Dockerfile --project-name=${{ github.repository }} --org=${{ secrets.SNYK_ORG_ID }} | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
|
|
||
| - name: Upload Snyk scan results to Snyk Web UI | ||
| if: always() | ||
| run: echo "Snyk scan results are automatically sent to the Snyk Web UI if SNYK_TOKEN is set." |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |||||||||
|
|
||||||||||
| // mongoose setup | ||||||||||
| require('./mongoose-db'); | ||||||||||
| require('./typeorm-db') | ||||||||||
| require('./typeorm-db'); | ||||||||||
|
|
||||||||||
| var st = require('st'); | ||||||||||
| var crypto = require('crypto'); | ||||||||||
|
|
@@ -13,7 +13,7 @@ var http = require('http'); | |||||||||
| var path = require('path'); | ||||||||||
| var ejsEngine = require('ejs-locals'); | ||||||||||
| var bodyParser = require('body-parser'); | ||||||||||
| var session = require('express-session') | ||||||||||
| var session = require('express-session'); | ||||||||||
| var methodOverride = require('method-override'); | ||||||||||
| var logger = require('morgan'); | ||||||||||
| var errorHandler = require('errorhandler'); | ||||||||||
|
|
@@ -23,11 +23,13 @@ var fileUpload = require('express-fileupload'); | |||||||||
| var dust = require('dustjs-linkedin'); | ||||||||||
| var dustHelpers = require('dustjs-helpers'); | ||||||||||
| var cons = require('consolidate'); | ||||||||||
| const hbs = require('hbs') | ||||||||||
| const hbs = require('hbs'); | ||||||||||
| const fs = require('fs'); | ||||||||||
| const cp = require('child_process'); // Used for RCE | ||||||||||
|
|
||||||||||
| var app = express(); | ||||||||||
| var routes = require('./routes'); | ||||||||||
| var routesUsers = require('./routes/users.js') | ||||||||||
| var routesUsers = require('./routes/users.js'); | ||||||||||
|
|
||||||||||
| // all environments | ||||||||||
| app.set('port', process.env.PORT || 3001); | ||||||||||
|
|
@@ -42,17 +44,76 @@ app.use(methodOverride()); | |||||||||
| app.use(session({ | ||||||||||
| secret: 'keyboard cat', | ||||||||||
| name: 'connect.sid', | ||||||||||
| cookie: { path: '/' } | ||||||||||
| })) | ||||||||||
| cookie: { path: '/', httpOnly: false, secure: false } | ||||||||||
| })); | ||||||||||
| app.use(bodyParser.json()); | ||||||||||
| app.use(bodyParser.urlencoded({ extended: false })); | ||||||||||
| app.use(fileUpload()); | ||||||||||
|
|
||||||||||
|
|
||||||||||
| app.post('/login', (req, res) => { | ||||||||||
| let { username, password } = req.body; | ||||||||||
| let sqlQuery = `SELECT * FROM users WHERE username = '${username}' AND password = '${password}'`; | ||||||||||
|
|
||||||||||
|
|
||||||||||
| console.log('Executing Query: ', sqlQuery); | ||||||||||
| res.send('Login attempt recorded.'); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
|
|
||||||||||
| app.post('/upload', (req, res) => { | ||||||||||
| if (!req.files || Object.keys(req.files).length === 0) { | ||||||||||
| return res.status(400).send('No files were uploaded.'); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| let uploadedFile = req.files.file; | ||||||||||
| let uploadPath = './uploads/' + uploadedFile.name; | ||||||||||
|
|
||||||||||
| // **Save the file without validating its type** | ||||||||||
| uploadedFile.mv(uploadPath, function (err) { | ||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||
| let uploadedFile = req.files.file; |
Step 6 - 10 app.js#L70
Step 11 - 12
Line 73 in 5eb016e
| uploadedFile.mv(uploadPath, function (err) { |
⚡ Fix this issue by replying with the following command: @snyk /fix
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.
Path Traversal
Unsanitized input from an uploaded file flows into mv, where it is used as a path. This may result in a Path Traversal vulnerability and allow an attacker to delete arbitrary files.
Line 73 | CWE-23 | Priority score 808 | Learn more about this vulnerability
Data flow: 12 steps
Step 1 - 5
Line 69 in 5eb016e
| let uploadedFile = req.files.file; |
Step 6 - 10 app.js#L70
Step 11 - 12
Line 73 in 5eb016e
| uploadedFile.mv(uploadPath, function (err) { |
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.
Cross-site Scripting (XSS)
Unsanitized input from an uploaded file flows into send, where it is used to render an HTML page returned to the user. This may result in a Cross-Site Scripting attack (XSS).
Line 74 | CWE-79 | Priority score 815 | Learn more about this vulnerability
Data flow: 9 steps
Step 1 - 5
Line 69 in 5eb016e
| let uploadedFile = req.files.file; |
Step 6 - 7 app.js#L73
Step 8 - 9
Line 74 in 5eb016e
| if (err) return res.status(500).send(err); |
⚡ Fix this issue by replying with the following command: @snyk /fix
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.
Cross-site Scripting (XSS)
Unsanitized input from an uploaded file flows into send, where it is used to render an HTML page returned to the user. This may result in a Cross-Site Scripting attack (XSS).
Line 74 | CWE-79 | Priority score 815 | Learn more about this vulnerability
Data flow: 9 steps
Step 1 - 5
Line 69 in 5eb016e
| let uploadedFile = req.files.file; |
Step 6 - 7 app.js#L73
Step 8 - 9
Line 74 in 5eb016e
| if (err) return res.status(500).send(err); |
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.
Command Injection
Unsanitized input from an uploaded file flows into child_process.exec, where it is used to build a shell command. This may result in a Command Injection vulnerability.
Line 77 | CWE-78 | Priority score 808 | Learn more about this vulnerability
Data flow: 13 steps
Step 1 - 5
Line 69 in 5eb016e
| let uploadedFile = req.files.file; |
Step 6 - 10 app.js#L70
Step 11 - 13
Line 77 in 5eb016e
| cp.exec(`node ${uploadPath}`, (error, stdout, stderr) => { |
⚡ Fix this issue by replying with the following command: @snyk /fix
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.
Command Injection
Unsanitized input from an uploaded file flows into child_process.exec, where it is used to build a shell command. This may result in a Command Injection vulnerability.
Line 77 | CWE-78 | Priority score 808 | Learn more about this vulnerability
Data flow: 13 steps
Step 1 - 5
Line 69 in 5eb016e
| let uploadedFile = req.files.file; |
Step 6 - 10 app.js#L70
Step 11 - 13
Line 77 in 5eb016e
| cp.exec(`node ${uploadPath}`, (error, stdout, stderr) => { |
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.
Cross-site Scripting (XSS)
Unsanitized input from an HTTP parameter flows into send, where it is used to render an HTML page returned to the user. This may result in a Cross-Site Scripting attack (XSS).
Line 91 | CWE-79 | Priority score 815 | Learn more about this vulnerability
Data flow: 10 steps
Step 1 - 7
Line 88 in 5eb016e
| let username = req.query.username || 'Guest'; |
Step 8 - 10
Line 91 in 5eb016e
| res.send(`<h1>Welcome, ${username}</h1><script>alert('XSS!');</script>`); |
⚡ Fix this issue by replying with the following command: @snyk /fix
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.
Cross-site Scripting (XSS)
Unsanitized input from an HTTP parameter flows into send, where it is used to render an HTML page returned to the user. This may result in a Cross-Site Scripting attack (XSS).
Line 91 | CWE-79 | Priority score 815 | Learn more about this vulnerability
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.
Server-Side Request Forgery (SSRF)
Unsanitized input from the HTTP request body flows into http.get, where it is used as an URL to perform a request. This may result in a Server-Side Request Forgery vulnerability.
Line 105 | CWE-918 | Priority score 808 | Learn more about this vulnerability
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.
Server-Side Request Forgery (SSRF)
Unsanitized input from the HTTP request body flows into http.get, where it is used as an URL to perform a request. This may result in a Server-Side Request Forgery vulnerability.
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.
Cookiehas the Secure attribute set tofalse. Set it to true to protect the cookie from man-in-the-middle attacks.Line 47 | CWE-614 | Priority score 408
Data flow: 2 steps
Step 1 - 2nodejs-goof/app.js
Line 47 in 5eb016e
⚡ Fix this issue by replying with the following command:
@snyk /fix