Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2cb1766
Create trivy.yml
austenstone Aug 7, 2024
143237e
Merge pull request #5 from octodemo/austenstone-patch-1
austenstone Aug 7, 2024
8aba916
chore: Remove unused trivy template and update trivy workflow
austenstone Aug 7, 2024
0000110
chore: Update trivy workflow to output results in SARIF format
austenstone Aug 7, 2024
96c60f2
Merge pull request #7 from octodemo/trivy
austenstone Aug 7, 2024
89a6a3a
chore: Add create product functionality patch task
austenstone Aug 15, 2024
e502560
Merge pull request #11 from octodemo/patch-functionality
austenstone Aug 15, 2024
e9cb126
Update trivy.yml
austenstone Sep 24, 2024
1594d52
Merge pull request #14 from octodemo/austenstone-patch-1
austenstone Sep 24, 2024
75c3dba
Update trivy.yml
austenstone Sep 24, 2024
1b091f4
Update trivy.yml
austenstone Sep 24, 2024
d9d7030
Enhance trivy.yml to modify SARIF output for Dockerfile locations
austenstone Sep 24, 2024
32037bc
Set file permissions for SARIF output file
austenstone Sep 24, 2024
9a9cda6
Add debugging steps before setting file permissions for SARIF output
austenstone Sep 24, 2024
9529108
Use sudo to set file permissions for SARIF output
austenstone Sep 24, 2024
020f31d
Update Dockerfile
austenstone Sep 24, 2024
c96e6c9
Remove unnecessary debug commands from trivy.yml
austenstone Sep 24, 2024
6974c48
Merge pull request #15 from octodemo/austenstone-patch-1
austenstone Sep 25, 2024
4f9c8cb
Create codacy.yml
austenstone Sep 27, 2024
aca5ab5
Update codacy.yml
austenstone Sep 27, 2024
7e0669c
Create lscpu.yml
austenstone Sep 30, 2024
952adb0
Delete .github/lscpu.yml
austenstone Sep 30, 2024
e4eff27
Create lscpu.yml
austenstone Sep 30, 2024
626ea8f
Update License section in README.md
austenstone Oct 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Codacy Security Scan

on:
push:
branches: [ "master", "main" ]
pull_request:
branches: [ "master", "main" ]

jobs:
codacy-security-scan:
name: Codacy Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main

- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@master
with:
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will hand over control about PR rejection to the GitHub side
max-allowed-issues: 2147483647
tool: issues

# archive the SARIF file generated in the previous step
- name: Archive SARIF results file
uses: actions/upload-artifact@v4
with:
path: results.sarif

# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@main
with:
sarif_file: results.sarif
9 changes: 9 additions & 0 deletions .github/workflows/lscpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Get CPU Info

on: workflow_dispatch

jobs:
lscpu:
runs-on: ubuntu-latest
steps:
- run: lscpu
69 changes: 69 additions & 0 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: trivy

on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '24 17 * * 1'

permissions:
contents: read

jobs:
build:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
name: Build
runs-on: "ubuntu-20.04"
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build an image from Dockerfile
run: |
docker build -t docker.io/my-organization/my-app:${{ github.sha }} .

- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'

- run: sudo chmod 666 trivy-results.sarif

- uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const sarif = fs.readFileSync('trivy-results.sarif', 'utf8');
const results = JSON.parse(sarif);
results.runs.forEach(run => {
run.results.forEach(result => {
result.locations.forEach(location => {
location.physicalLocation.artifactLocation.uri = 'Dockerfile';
});
});
});
fs.writeFileSync('trivy-results.sarif', JSON.stringify(results, null, 2));

- uses: actions/upload-artifact@v4
with:
name: 'results.sarif'
path: 'trivy-results.sarif'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
11 changes: 11 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Apply products_patch.diff",
"type": "shell",
"command": "git apply products_patch.diff",
"problemMatcher": []
}
]
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:19.4.0-bullseye-slim
FROM node:19.3.0-bullseye-slim

LABEL maintainer="Daniel García (cr0hn) [email protected]"

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,7 @@ I took ideas and how to explode it in NodeJS using these references:
# License

This project is released under license BSD.



123123123123
58 changes: 58 additions & 0 deletions products_patch.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
diff --git a/model/products.js b/model/products.js
index 6df3f92..9366003 100644
--- a/model/products.js
+++ b/model/products.js
@@ -49,12 +49,23 @@ function get_purcharsed(username) {

}

+function create(product) {
+ var q = "INSERT INTO products(name, description, price) VALUES('" +
+ product.name + "', '" +
+ product.description + "', '" +
+ product.price +
+ "');";
+
+ return db.one(q);
+}
+
var actions = {
"list": list_products,
"getProduct": getProduct,
"search": search,
"purchase": purchase,
- "getPurchased": get_purcharsed
+ "getPurchased": get_purcharsed,
+ "create": create
}

module.exports = actions;
diff --git a/routes/products.js b/routes/products.js
index 814f834..4d5d1fb 100644
--- a/routes/products.js
+++ b/routes/products.js
@@ -144,6 +144,24 @@ router.all('/products/buy', function(req, res, next) {

});

+router.all('/products/create', function(req, res, next) {
+ let params = null;
+ if (req.method == "GET"){
+ params = url.parse(req.url, true).query;
+ } else {
+ params = req.body;
+ }
+
+ let product = null;
+ product = {
+ name: params.name,
+ description: params.description,
+ price: params.price,
+ image: params.image,
+ username: req.session.user_name
+ }

+ db_products.create(product)
+});

module.exports = router;