Skip to content
Open
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include ./scripts/test.mk
include ./scripts/proto.mk
include ./scripts/utils.mk
include ./scripts/run.mk
include ./scripts/security.mk
include ./tools/tools.mk

# Sets the default make target to `build`.
Expand Down
10 changes: 8 additions & 2 deletions apps/evm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ FROM alpine:3.22.2
#hadolint ignore=DL3018
RUN apk --no-cache add ca-certificates curl

WORKDIR /root
RUN addgroup -g 1000 ev-node && \
adduser -u 1000 -G ev-node -s /bin/sh -D ev-node
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The adduser command uses the -D flag, which prevents the creation of a home directory. However, the subsequent WORKDIR /home/ev-node implies that /home/ev-node is intended to be the user's home directory. For consistency with apps/testapp/Dockerfile and clearer intent, it's better to allow adduser to create the home directory by removing the -D flag, or explicitly create it if -D is strictly necessary for other reasons. Removing -D is the most straightforward approach to align with the WORKDIR and chown commands.

    adduser -u 1000 -G ev-node -s /bin/sh ev-node


WORKDIR /home/ev-node

COPY --from=build-env /src/apps/evm/evm /usr/bin/evm
COPY apps/evm/entrypoint.sh /usr/bin/entrypoint.sh
RUN chmod +x /usr/bin/entrypoint.sh
RUN chmod +x /usr/bin/entrypoint.sh && \
chown -R ev-node:ev-node /home/ev-node

USER ev-node
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

ENTRYPOINT ["/usr/bin/entrypoint.sh"]
8 changes: 7 additions & 1 deletion apps/testapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM golang:1.25 AS base

#hadolint ignore=DL3018
RUN apt-get update && \

Check failure on line 4 in apps/testapp/Dockerfile

View workflow job for this annotation

GitHub Actions / lint / hadolint

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
Expand All @@ -27,8 +27,14 @@
#
FROM base

RUN groupadd -g 1000 ev-node && \
useradd -u 1000 -g ev-node -s /bin/sh -m ev-node

COPY --from=builder /go/bin/testapp /usr/bin

WORKDIR /apps
WORKDIR /home/ev-node
RUN chown -R ev-node:ev-node /home/ev-node

USER ev-node

ENTRYPOINT ["testapp"]
43 changes: 43 additions & 0 deletions scripts/security.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# security.mk - Security scanning with Trivy (https://trivy.dev)

TRIVY_IMAGE := aquasec/trivy:latest
TRIVY_SEVERITY ?= CRITICAL,HIGH
TRIVY_CACHE_VOLUME := trivy-cache

# Docker images to scan (space-separated, override or extend as needed)
SCAN_IMAGES ?= evstack:local-dev
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The SCAN_IMAGES variable defaults to evstack:local-dev. While the comment indicates it can be overridden, having a single specific image as the default might lead to other relevant images being missed during scans if the user doesn't explicitly configure this variable. Consider making this variable empty by default or providing a more generic placeholder, encouraging users to define the images they intend to scan, or adding a clear example of how to extend it for multiple images.


# Common docker run args for Trivy
TRIVY_RUN := docker run --rm \
-v $(TRIVY_CACHE_VOLUME):/root/.cache/ \
-e TRIVY_SEVERITY=$(TRIVY_SEVERITY)

## trivy-scan: Run all Trivy security scans (filesystem + Docker images)
trivy-scan: trivy-scan-fs trivy-scan-image
.PHONY: trivy-scan

## trivy-scan-fs: Scan repo for dependency vulnerabilities, misconfigs, and secrets
trivy-scan-fs:
@echo "--> Scanning repository filesystem with Trivy"
@$(TRIVY_RUN) \
-v $(CURDIR):/workspace \
$(TRIVY_IMAGE) \
fs --scanners vuln,misconfig,secret \
--severity $(TRIVY_SEVERITY) \
/workspace
@echo "--> Filesystem scan complete"
.PHONY: trivy-scan-fs

## trivy-scan-image: Scan built Docker images for vulnerabilities
trivy-scan-image:
@echo "--> Scanning Docker images with Trivy"
@for img in $(SCAN_IMAGES); do \
echo "--> Scanning image: $$img"; \
$(TRIVY_RUN) \
-v /var/run/docker.sock:/var/run/docker.sock \
$(TRIVY_IMAGE) \
image --severity $(TRIVY_SEVERITY) \
$$img; \
done
@echo "--> Image scan complete"
.PHONY: trivy-scan-image
8 changes: 7 additions & 1 deletion tools/local-da/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ FROM alpine:3.22.2
#hadolint ignore=DL3018
RUN apk --no-cache add ca-certificates curl

WORKDIR /root
RUN addgroup -g 1000 ev-node && \
adduser -u 1000 -G ev-node -s /bin/sh -D ev-node

WORKDIR /home/ev-node
RUN chown -R ev-node:ev-node /home/ev-node

COPY --from=build-env /src/build/local-da /usr/bin/local-da

USER ev-node

ENTRYPOINT ["/usr/bin/local-da"]
CMD ["-listen-all"]
Loading