File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ # # These should be flagged
2+
3+ # <expect-error>
4+ ADD ./source /destination
5+
6+ # <expect-error>
7+ ADD https://example.com/file.tar.gz /destination/
8+
9+ # <expect-error>
10+ ADD archive.tar.gz /extract-here/
11+
12+ # <expect-error>
13+ ADD ["file1" , "file2" , "/dest/" ]
14+
15+ # <expect-error>
16+ ADD --chown=1000:1000 sourcefile /destination/
17+
18+ # # These are safe and should not be flagged
19+
20+ # Using COPY instead of ADD
21+ COPY ./source /destination
22+
23+ COPY ["file1" , "file2" , "/dest/" ]
24+
25+ # Comments containing "ADD" should not trigger detection
26+ # This is an example: ADD should not be used
Original file line number Diff line number Diff line change 1+ language : dockerfile
2+ name : avoid_add
3+ message : " Avoid using the 'ADD' instruction in Dockerfiles, prefer 'COPY' instead for copying files"
4+ category : antipattern
5+ severity : warning
6+
7+ pattern : |
8+ (add_instruction) @avoid_add
9+
10+ description : |
11+ The 'ADD' instruction in Dockerfiles should be avoided due to its unintended side effects,
12+ such as automatic archive extraction and remote URL downloads, which can introduce security risks.
13+ If you only need to copy files into the image, prefer the use of 'COPY'.
You can’t perform that action at this time.
0 commit comments