We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f8c8819 commit 9b53a1dCopy full SHA for 9b53a1d
evaluation_plans/osps/build_release/steps.go
@@ -236,7 +236,8 @@ func getLinks(data data.Payload) []string {
236
}
237
238
func insecureURI(uri string) bool {
239
- if strings.HasPrefix(uri, "https://") ||
+ if strings.TrimSpace(uri) == "" ||
240
+ strings.HasPrefix(uri, "https://") ||
241
strings.HasPrefix(uri, "ssh:") ||
242
strings.HasPrefix(uri, "git:") ||
243
strings.HasPrefix(uri, "git@") {
evaluation_plans/osps/build_release/steps_test.go
@@ -124,6 +124,29 @@ func TestMultipleVariables(t *testing.T) {
124
125
126
127
+func TestInsecureURI(t *testing.T) {
128
+ tests := []struct {
129
+ name string
130
+ uri string
131
+ expected bool
132
+ }{
133
+ {"empty string is not insecure", "", false},
134
+ {"whitespace string is not insecure", " ", false},
135
+ {"https is not insecure", "https://example.com", false},
136
+ {"ssh is not insecure", "ssh://example.com", false},
137
+ {"git protocol is not insecure", "git://example.com", false},
138
+ {"git@ is not insecure", "git@github.com:org/repo.git", false},
139
+ {"http is insecure", "http://example.com", true},
140
+ {"ftp is insecure", "ftp://example.com", true},
141
+ }
142
+
143
+ for _, tt := range tests {
144
+ t.Run(tt.name, func(t *testing.T) {
145
+ assert.Equal(t, tt.expected, insecureURI(tt.uri), tt.name)
146
+ })
147
148
+}
149
150
func TestUnTrustedVarsRegex(t *testing.T) {
151
152
expression, err := regexp.Compile(untrustedVarsRegex)
0 commit comments