github.com/google/osv-scalibr@v0.4.1/artifact/image/testfixtures/symlinks/Dockerfile (about)

     1  # Use Alpine as the builder since the final image is built on scratch
     2  # which doesn't contain the `ln` command to generate symlinks.
     3  FROM alpine:latest as builder
     4  
     5  RUN mkdir dir1
     6  RUN mkdir dir2
     7  RUN mkdir dir2/dir3
     8  
     9  RUN echo "sample text" > dir1/sample.txt
    10  
    11  RUN ln -s /dir1/sample.txt /dir1/absolute-symlink.txt
    12  RUN ln -s ./sample.txt /dir1/relative-dot-symlink.txt
    13  RUN ln -s sample.txt /dir1/relative-symlink.txt
    14  RUN ln -s absolute-symlink.txt /dir1/chain-symlink.txt
    15  RUN ln -s ../../secret.txt /dir1/attack-symlink.txt
    16  RUN ln -s /../secret.txt /dir1/attack-symlink-absolute.txt
    17  
    18  RUN ln -s ../../dir1/sample.txt /dir2/dir3/relative-subfolder-symlink.txt
    19  RUN ln -s /dir1/sample.txt /dir2/dir3/absolute-subfolder-symlink.txt
    20  RUN ln -s /dir1/chain-symlink.txt /dir2/dir3/absolute-chain-symlink.txt
    21  RUN ln -s /dir2/../dir1/sample.txt /dir2/dir3/absolute-symlink-inside-root.txt
    22  
    23  # - root
    24  #   - dir1
    25  #     - sample.txt
    26  #     - absolute-symlink.txt -> /dir1/sample.txt
    27  #     - relative-dot-symlink.txt -> ./sample.txt
    28  #     - relative-symlink.txt -> sample.txt
    29  #     - chain-symlink.txt -> absolute-symlink.txt
    30  #     - attack-symlink.txt -> ../../secret.txt
    31  #     - attack-symlink-absolute.txt -> /../secret.txt
    32  #   - dir2
    33  #     - dir3
    34  #       - relative-subfolder-symlink.txt -> ../../dir1/sample.txt
    35  #       - absolute-subfolder-symlink.txt -> /dir1/sample.txt
    36  #       - absolute-chain-symlink.txt -> /dir1/chain-symlink.txt
    37  #       - absolute-symlink-inside-root.txt -> /dir2/../dir1/sample.txt
    38  
    39  FROM scratch
    40  
    41  # Must copy over the entire directory to preserve the symlinks.
    42  COPY --from=builder /dir1/ /dir1/
    43  COPY --from=builder /dir2/ /dir2/