From ccb1d466015d48bf037e655db58d54dd5497306d Mon Sep 17 00:00:00 2001 From: Austen Stone Date: Wed, 7 Aug 2024 12:18:12 -0400 Subject: [PATCH 01/10] chore: Add create product functionality --- model/products.js | 13 ++++++++++++- routes/products.js | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/model/products.js b/model/products.js index 6df3f921..93660039 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 814f834b..82958174 100644 --- a/routes/products.js +++ b/routes/products.js @@ -144,6 +144,25 @@ 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; From 620e7cee8e8bc38ab8ef87d313c5695fb9ff2822 Mon Sep 17 00:00:00 2001 From: Austen Stone Date: Wed, 7 Aug 2024 12:24:32 -0400 Subject: [PATCH 02/10] Update Dockerfile to use Node.js version 18 instead of 19.4.0-bullseye-slim. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 42f52410..210d1067 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:19.4.0-bullseye-slim +FROM node:18-bullseye-slim LABEL maintainer="Daniel García (cr0hn) cr0hn@cr0hn.com" From a4b47ee2fb56e4ef50de156dd98b774beacae1a5 Mon Sep 17 00:00:00 2001 From: Austen Stone Date: Wed, 7 Aug 2024 12:28:56 -0400 Subject: [PATCH 03/10] Update Dockerfile to use Node.js version 18.5.0-bullseye-slim. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 210d1067..38f2ec1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18-bullseye-slim +FROM node:18.5.0-bullseye-slim LABEL maintainer="Daniel García (cr0hn) cr0hn@cr0hn.com" From 51b76d4d71de659b4deb5e9e6c7afe7c141371fe Mon Sep 17 00:00:00 2001 From: Austen Stone Date: Wed, 7 Aug 2024 12:32:58 -0400 Subject: [PATCH 04/10] Update Dockerfile to use Node.js version 18.5.0-buster and install libssl1.0.0 --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 38f2ec1a..5fba2081 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18.5.0-bullseye-slim +FROM node:18.5.0-buster LABEL maintainer="Daniel García (cr0hn) cr0hn@cr0hn.com" @@ -6,6 +6,8 @@ ENV STAGE "DOCKER" RUN apt-get update && apt-get install -y netcat +RUN apt-get install -y libssl1.0.0 + # Build app folders RUN mkdir /app WORKDIR /app From cda8db1cd1cc2f0a3beae77cb2b5679f66aa9ae6 Mon Sep 17 00:00:00 2001 From: Austen Stone Date: Wed, 7 Aug 2024 12:36:00 -0400 Subject: [PATCH 05/10] chore: Update Dockerfile to use libssl1.1 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5fba2081..3f484c49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ ENV STAGE "DOCKER" RUN apt-get update && apt-get install -y netcat -RUN apt-get install -y libssl1.0.0 +RUN apt-get install -y libssl1.1 # Build app folders RUN mkdir /app From e5439ec152d23b8976fb61444b366a90d6ea1a3e Mon Sep 17 00:00:00 2001 From: Austen Stone Date: Wed, 7 Aug 2024 13:00:07 -0400 Subject: [PATCH 06/10] Update Dockerfile to use Node.js version 18.1.0-buster-slim --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3f484c49..95b8230a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18.5.0-buster +FROM node:18.1.0-buster-slim LABEL maintainer="Daniel García (cr0hn) cr0hn@cr0hn.com" From 0c38d320cfd7f8975b699a83a4b88e2d7e3a9799 Mon Sep 17 00:00:00 2001 From: Austen Stone Date: Wed, 7 Aug 2024 13:04:52 -0400 Subject: [PATCH 07/10] Update Dockerfile to use Golang for building the app and install a vulnerable version of curl --- Dockerfile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 95b8230a..e91ea3e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,13 @@ -FROM node:18.1.0-buster-slim +FROM golang:1.16-buster AS build + +WORKDIR /app + +COPY go.mod . +RUN go mod download + +COPY *.go . + +RUN go build -o app LABEL maintainer="Daniel García (cr0hn) cr0hn@cr0hn.com" @@ -6,6 +15,9 @@ ENV STAGE "DOCKER" RUN apt-get update && apt-get install -y netcat +# install vulnerable version of a library +RUN apt-get install -y curl=7.64.0-4+deb10u2 + RUN apt-get install -y libssl1.1 # Build app folders From f6fe904e952e2c27637db7289813f8b4af076db1 Mon Sep 17 00:00:00 2001 From: Austen Stone Date: Wed, 7 Aug 2024 13:05:27 -0400 Subject: [PATCH 08/10] Update Dockerfile to use Golang for building the app and remove unnecessary comments and commands --- Dockerfile | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index e91ea3e3..732cb7c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,35 +2,35 @@ FROM golang:1.16-buster AS build WORKDIR /app -COPY go.mod . +# COPY go.mod . RUN go mod download -COPY *.go . +# COPY *.go . -RUN go build -o app +# RUN go build -o app -LABEL maintainer="Daniel García (cr0hn) cr0hn@cr0hn.com" +# LABEL maintainer="Daniel García (cr0hn) cr0hn@cr0hn.com" -ENV STAGE "DOCKER" +# ENV STAGE "DOCKER" -RUN apt-get update && apt-get install -y netcat +# RUN apt-get update && apt-get install -y netcat -# install vulnerable version of a library -RUN apt-get install -y curl=7.64.0-4+deb10u2 +# # install vulnerable version of a library +# RUN apt-get install -y curl=7.64.0-4+deb10u2 -RUN apt-get install -y libssl1.1 +# RUN apt-get install -y libssl1.1 -# Build app folders -RUN mkdir /app -WORKDIR /app +# # Build app folders +# RUN mkdir /app +# WORKDIR /app -# Install depends -COPY package.json /app/ -RUN npm install +# # Install depends +# COPY package.json /app/ +# RUN npm install -# Bundle code -COPY . /app +# # Bundle code +# COPY . /app -EXPOSE 3000 +# EXPOSE 3000 -CMD [ "npm", "start" ] +# CMD [ "npm", "start" ] From f92a96faa9f8c0560a562dcba3658158609154ec Mon Sep 17 00:00:00 2001 From: Austen Stone Date: Wed, 7 Aug 2024 13:05:47 -0400 Subject: [PATCH 09/10] Update Dockerfile to remove unnecessary comments and commands --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 732cb7c7..88a7f81a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.16-buster AS build WORKDIR /app # COPY go.mod . -RUN go mod download +# RUN go mod download # COPY *.go . From c7a3d593cf7a017d14781c31c52fc6e246051a04 Mon Sep 17 00:00:00 2001 From: Austen Stone Date: Thu, 15 Aug 2024 13:24:24 -0400 Subject: [PATCH 10/10] Update Dockerfile to use Node.js for building the app and remove unnecessary comments and commands --- Dockerfile | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/Dockerfile b/Dockerfile index 88a7f81a..25089c47 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,36 +1,22 @@ -FROM golang:1.16-buster AS build +FROM node:19.4.0-bullseye-slim -WORKDIR /app - -# COPY go.mod . -# RUN go mod download - -# COPY *.go . - -# RUN go build -o app +LABEL maintainer="Daniel García (cr0hn) cr0hn@cr0hn.com" -# LABEL maintainer="Daniel García (cr0hn) cr0hn@cr0hn.com" +ENV STAGE "DOCKER" -# ENV STAGE "DOCKER" +RUN apt-get update && apt-get install -y netcat -# RUN apt-get update && apt-get install -y netcat - -# # install vulnerable version of a library -# RUN apt-get install -y curl=7.64.0-4+deb10u2 - -# RUN apt-get install -y libssl1.1 - -# # Build app folders -# RUN mkdir /app -# WORKDIR /app +# Build app folders +RUN mkdir /app +WORKDIR /app -# # Install depends -# COPY package.json /app/ -# RUN npm install +# Install depends +COPY package.json /app/ +RUN npm install -# # Bundle code -# COPY . /app +# Bundle code +COPY . /app -# EXPOSE 3000 +EXPOSE 3000 -# CMD [ "npm", "start" ] +CMD [ "npm", "start" ] \ No newline at end of file