Skip to content

Commit e7b064b

Browse files
committed
cstrans-df-run: improve matching of comments
.. so that `cspodman` can successfully scan quay-builder-container-v3.10.0-15 Related: https://issues.redhat.com/browse/OSH-391
1 parent bb1634e commit e7b064b

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed

src/cstrans-df-run.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class DockerFileTransformer {
6262
const RE reLineCont_ = RE("(^.*[^\\\\])\\\\$");
6363

6464
/// match in-line comments
65-
const RE reComment_ = RE("^ *#.*$");
65+
const RE reComment_ = RE("^\\s*#.*$");
6666
};
6767

6868
/// parse serialized list in the form: "item1", "item2", ...

tests/cstrans-df-run/0010-stdin.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#@follow_tag(registry-proxy.engineering.redhat.com/rh-osbs/openshift-golang-builder:v1.19.10-202306161322.el8.g42c8e14)
2+
FROM registry-proxy.engineering.redhat.com/rh-osbs/openshift-golang-builder:v1.19.10-202306161322.el8.g42c8e14 AS builder
3+
4+
COPY $REMOTE_SOURCE $REMOTE_SOURCE_DIR
5+
WORKDIR $REMOTE_SOURCE_DIR/app
6+
USER root
7+
RUN dnf install -y --setopt=tsflags=nodocs git
8+
RUN sed -i 's/CGO_ENABLED=0 //;s/containers_image_openpgp/& strictfipsruntime/' Makefile
9+
RUN go mod vendor && \
10+
GOEXPERIMENT=strictfipsruntime make build VERSION=${CI_CONTAINER_VERSION}
11+
12+
#@follow_tag(registry.redhat.io/ubi8/podman)
13+
FROM registry.redhat.io/ubi8/podman:8.8-14.1697647490
14+
15+
LABEL com.redhat.component="quay-builder-container"
16+
LABEL name="quay/quay-builder-rhel8"
17+
LABEL version=${CI_CONTAINER_VERSION}
18+
LABEL io.k8s.display-name="Red Hat Quay - Builder"
19+
LABEL io.k8s.description="Red Hat Quay image builder"
20+
LABEL summary="Red Hat Quay image builder"
21+
LABEL maintainer "[email protected]"
22+
23+
COPY --from=builder $REMOTE_SOURCE_DIR/app/bin/quay-builder /usr/local/bin/quay-builder
24+
COPY --from=builder $REMOTE_SOURCE_DIR/app/buildpack/ssh-git.sh /ssh-git.sh
25+
COPY --from=builder $REMOTE_SOURCE_DIR/app/entrypoint.sh /home/podman/entrypoint.sh
26+
27+
RUN set -ex\
28+
; dnf install -y --setopt=tsflags=nodocs --setopt=skip_missing_names_on_install=False git wget \
29+
; dnf -y update && dnf -y -q clean all
30+
31+
# Rootless/unprivileged buildah configurations
32+
# https://github.com/containers/buildah/blob/main/docs/tutorials/05-openshift-rootless-build.md
33+
RUN touch /etc/subgid /etc/subuid && \
34+
chmod g=u /etc/subgid /etc/subuid /etc/passwd && \
35+
echo 'podman:100000:65536' > /etc/subuid && echo 'podman:100000:65536' > /etc/subgid && \
36+
# Set driver to VFS, which doesn't require host modifications compared to overlay
37+
# Set shortname aliasing to permissive - https://www.redhat.com/sysadmin/container-image-short-names
38+
mkdir -p /home/podman/.config/containers && \
39+
(echo '[storage]';echo 'driver = "vfs"') > /home/podman/.config/containers/storage.conf && \
40+
sed -i 's/short-name-mode="enforcing"/short-name-mode="permissive"/g' /etc/containers/registries.conf && \
41+
mkdir /certs /home/podman/.config/cni && chown podman:podman /certs /home/podman/.config/cni
42+
43+
VOLUME ["/tmp", "/certs"]
44+
45+
WORKDIR /home/podman
46+
47+
USER podman
48+
49+
ENTRYPOINT ["sh", "/home/podman/entrypoint.sh"]

tests/cstrans-df-run/0010-stdout.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#@follow_tag(registry-proxy.engineering.redhat.com/rh-osbs/openshift-golang-builder:v1.19.10-202306161322.el8.g42c8e14)
2+
FROM registry-proxy.engineering.redhat.com/rh-osbs/openshift-golang-builder:v1.19.10-202306161322.el8.g42c8e14 AS builder
3+
4+
COPY $REMOTE_SOURCE $REMOTE_SOURCE_DIR
5+
WORKDIR $REMOTE_SOURCE_DIR/app
6+
USER root
7+
RUN ["/opt/cov-sa-2019.09/bin/cov-build", "--dir=/cov", "--append-log", "sh", "-c", "dnf install -y --setopt=tsflags=nodocs git"]
8+
RUN ["/opt/cov-sa-2019.09/bin/cov-build", "--dir=/cov", "--append-log", "sh", "-c", "sed -i 's/CGO_ENABLED=0 //;s/containers_image_openpgp/& strictfipsruntime/' Makefile"]
9+
RUN ["/opt/cov-sa-2019.09/bin/cov-build", "--dir=/cov", "--append-log", "sh", "-c", "go mod vendor && GOEXPERIMENT=strictfipsruntime make build VERSION=${CI_CONTAINER_VERSION}"]
10+
11+
#@follow_tag(registry.redhat.io/ubi8/podman)
12+
FROM registry.redhat.io/ubi8/podman:8.8-14.1697647490
13+
14+
LABEL com.redhat.component="quay-builder-container"
15+
LABEL name="quay/quay-builder-rhel8"
16+
LABEL version=${CI_CONTAINER_VERSION}
17+
LABEL io.k8s.display-name="Red Hat Quay - Builder"
18+
LABEL io.k8s.description="Red Hat Quay image builder"
19+
LABEL summary="Red Hat Quay image builder"
20+
LABEL maintainer "[email protected]"
21+
22+
COPY --from=builder $REMOTE_SOURCE_DIR/app/bin/quay-builder /usr/local/bin/quay-builder
23+
COPY --from=builder $REMOTE_SOURCE_DIR/app/buildpack/ssh-git.sh /ssh-git.sh
24+
COPY --from=builder $REMOTE_SOURCE_DIR/app/entrypoint.sh /home/podman/entrypoint.sh
25+
26+
RUN ["/opt/cov-sa-2019.09/bin/cov-build", "--dir=/cov", "--append-log", "sh", "-c", "set -ex\t; dnf install -y --setopt=tsflags=nodocs --setopt=skip_missing_names_on_install=False git wget \t; dnf -y update && dnf -y -q clean all"]
27+
28+
# Rootless/unprivileged buildah configurations
29+
# https://github.com/containers/buildah/blob/main/docs/tutorials/05-openshift-rootless-build.md
30+
RUN ["/opt/cov-sa-2019.09/bin/cov-build", "--dir=/cov", "--append-log", "sh", "-c", "touch /etc/subgid /etc/subuid && chmod g=u /etc/subgid /etc/subuid /etc/passwd && echo 'podman:100000:65536' > /etc/subuid && echo 'podman:100000:65536' > /etc/subgid && \tmkdir -p /home/podman/.config/containers && (echo '[storage]';echo 'driver = \"vfs\"') > /home/podman/.config/containers/storage.conf && \\ "]
31+
sed -i 's/short-name-mode="enforcing"/short-name-mode="permissive"/g' /etc/containers/registries.conf && \
32+
mkdir /certs /home/podman/.config/cni && chown podman:podman /certs /home/podman/.config/cni
33+
34+
VOLUME ["/tmp", "/certs"]
35+
36+
WORKDIR /home/podman
37+
38+
USER podman
39+
40+
ENTRYPOINT ["sh", "/home/podman/entrypoint.sh"]

tests/cstrans-df-run/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ tests_cstrans_df_run(0006)
3535
tests_cstrans_df_run(0007)
3636
tests_cstrans_df_run(0008)
3737
tests_cstrans_df_run(0009)
38+
tests_cstrans_df_run(0010)

0 commit comments

Comments
 (0)