@@ -41,8 +41,82 @@ var lintTests = integration.TestFuncs(
41
41
testBaseImagePlatformMismatch ,
42
42
testAllTargetUnmarshal ,
43
43
testRedundantTargetPlatform ,
44
+ testSecretsUsedInArgOrEnv ,
44
45
)
45
46
47
+ func testSecretsUsedInArgOrEnv (t * testing.T , sb integration.Sandbox ) {
48
+ dockerfile := []byte (`
49
+ FROM scratch
50
+ ARG SECRET_PASSPHRASE
51
+ ENV SUPER_Secret=foo
52
+ ENV password=bar secret=baz
53
+ ARG super_duper_secret_token=foo auth=bar
54
+ ENV apikey=bar sunflower=foo
55
+ ENV git_key=
56
+ ` )
57
+ checkLinterWarnings (t , sb , & lintTestParams {
58
+ Dockerfile : dockerfile ,
59
+ Warnings : []expectedLintWarning {
60
+ {
61
+ RuleName : "SecretsUsedInArgOrEnv" ,
62
+ Description : "Potentially sensitive data should not be used in the ARG or ENV commands" ,
63
+ Detail : `Secrets should not be used in the ARG or ENV commands (key named "SECRET_PASSPHRASE")` ,
64
+ Level : 1 ,
65
+ Line : 3 ,
66
+ },
67
+ {
68
+ RuleName : "SecretsUsedInArgOrEnv" ,
69
+ Description : "Potentially sensitive data should not be used in the ARG or ENV commands" ,
70
+ Detail : `Secrets should not be used in the ARG or ENV commands (key named "SUPER_Secret")` ,
71
+ Level : 1 ,
72
+ Line : 4 ,
73
+ },
74
+ {
75
+ RuleName : "SecretsUsedInArgOrEnv" ,
76
+ Description : "Potentially sensitive data should not be used in the ARG or ENV commands" ,
77
+ Detail : `Secrets should not be used in the ARG or ENV commands (key named "password")` ,
78
+ Level : 1 ,
79
+ Line : 5 ,
80
+ },
81
+ {
82
+ RuleName : "SecretsUsedInArgOrEnv" ,
83
+ Description : "Potentially sensitive data should not be used in the ARG or ENV commands" ,
84
+ Detail : `Secrets should not be used in the ARG or ENV commands (key named "secret")` ,
85
+ Level : 1 ,
86
+ Line : 5 ,
87
+ },
88
+ {
89
+ RuleName : "SecretsUsedInArgOrEnv" ,
90
+ Description : "Potentially sensitive data should not be used in the ARG or ENV commands" ,
91
+ Detail : `Secrets should not be used in the ARG or ENV commands (key named "super_duper_secret_token")` ,
92
+ Level : 1 ,
93
+ Line : 6 ,
94
+ },
95
+ {
96
+ RuleName : "SecretsUsedInArgOrEnv" ,
97
+ Description : "Potentially sensitive data should not be used in the ARG or ENV commands" ,
98
+ Detail : `Secrets should not be used in the ARG or ENV commands (key named "auth")` ,
99
+ Level : 1 ,
100
+ Line : 6 ,
101
+ },
102
+ {
103
+ RuleName : "SecretsUsedInArgOrEnv" ,
104
+ Description : "Potentially sensitive data should not be used in the ARG or ENV commands" ,
105
+ Detail : `Secrets should not be used in the ARG or ENV commands (key named "apikey")` ,
106
+ Level : 1 ,
107
+ Line : 7 ,
108
+ },
109
+ {
110
+ RuleName : "SecretsUsedInArgOrEnv" ,
111
+ Description : "Potentially sensitive data should not be used in the ARG or ENV commands" ,
112
+ Detail : `Secrets should not be used in the ARG or ENV commands (key named "git_key")` ,
113
+ Level : 1 ,
114
+ Line : 8 ,
115
+ },
116
+ },
117
+ })
118
+ }
119
+
46
120
func testAllTargetUnmarshal (t * testing.T , sb integration.Sandbox ) {
47
121
dockerfile := []byte (`
48
122
FROM scratch AS first
@@ -858,7 +932,7 @@ HEALTHCHECK CMD ["/myotherapp"]
858
932
func testLegacyKeyValueFormat (t * testing.T , sb integration.Sandbox ) {
859
933
dockerfile := []byte (`
860
934
FROM scratch
861
- ENV key value
935
+ ENV testkey value
862
936
LABEL key value
863
937
` )
864
938
checkLinterWarnings (t , sb , & lintTestParams {
@@ -885,7 +959,7 @@ LABEL key value
885
959
886
960
dockerfile = []byte (`
887
961
FROM scratch
888
- ENV key =value
962
+ ENV testkey =value
889
963
LABEL key=value
890
964
` )
891
965
checkLinterWarnings (t , sb , & lintTestParams {Dockerfile : dockerfile })
@@ -896,7 +970,7 @@ LABEL key=value
896
970
FROM scratch AS a
897
971
898
972
FROM a AS b
899
- ENV key value
973
+ ENV testkey value
900
974
LABEL key value
901
975
902
976
FROM a AS c
0 commit comments