Skip to content

Commit

Permalink
Merge pull request #117 from snyk/fix/remove-extra-error-log
Browse files Browse the repository at this point in the history
fix: remove extra error log
  • Loading branch information
p0tr3c committed Dec 9, 2021
2 parents 354123a + a0ecb99 commit bc2df8a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
6 changes: 4 additions & 2 deletions cmd/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ $ snyk-iac-rules test --help
return nil
},
PreRunE: func(cmd *cobra.Command, args []string) error {
ruleId := strings.ToUpper(templateParams.RuleID)

// make sure rule name doesn't have any whitespace in it
if strings.Contains(templateParams.RuleID, " ") {
if strings.Contains(ruleId, " ") {
return fmt.Errorf("Rule name cannot contain whitespace")
}

// make sure rule name doesn't belong to Snyk namespace
if strings.HasPrefix(templateParams.RuleID, "SNYK-") {
if strings.HasPrefix(ruleId, "SNYK-") {
return fmt.Errorf("Rule name cannot start with \"SNYK-\"")
}

Expand Down
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"os"

"github.com/snyk/snyk-iac-rules/builtins"
Expand All @@ -14,7 +13,6 @@ func main() {
builtins.RegisterTerraformPlanBuiltin()

if err := cmd.RootCommand.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
15 changes: 5 additions & 10 deletions spec/e2e/push_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ Describe './snyk-iac-rules push -r docker.io/test/test test.jpg'
It 'returns failing test status'
When call ./snyk-iac-rules push -r docker.io/test/test test.jpg
The status should be failure
The output should include 'The path must be to a generated .tar.gz bundle'
The stderr should be present
The stderr should include 'The path must be to a generated .tar.gz bundle'
End
End

Describe 'When call ./snyk-iac-rules push -r https://docker.io/test/test bundle.tar.gz'
It 'returns failing test status'
When call ./snyk-iac-rules push -r https://docker.io/test/test bundle.tar.gz
The status should be failure
The output should include 'The provided container registry includes a protocol. Please remove it and try again'
The stderr should be present
The stderr should include 'The provided container registry includes a protocol. Please remove it and try again'
End
End

Expand All @@ -44,17 +42,15 @@ Describe './snyk-iac-rules push -r docker.io/test/test bundle-incorrect.tar.gz'
It 'returns failing test status'
When call ./snyk-iac-rules push -r docker.io/test/test bundle-incorrect.tar.gz
The status should be failure
The output should include 'Failed to read from the provided path'
The stderr should be present
The stderr should include 'Failed to read from the provided path'
End
End

Describe './snyk-iac-rules push -r test bundle.tar.gz'
It 'returns failing test status'
When call ./snyk-iac-rules push -r test bundle.tar.gz
The status should be failure
The output should include 'The provided container registry is invalid'
The stderr should be present
The stderr should include 'The provided container registry is invalid'
End
End

Expand All @@ -64,8 +60,7 @@ Describe './snyk-iac-rules push -r docker.io/test/test bundle.tar.gz'
When call ./snyk-iac-rules push -r docker.io/test/test bundle.tar.gz
The status should be failure
The output should include 'bundle.tar.gz'
The output should include 'Failed to push bundle to container registry: server message: insufficient_scope: authorization failed'
The stderr should be present
The stderr should include 'Failed to push bundle to container registry: server message: insufficient_scope: authorization failed'
End
End

Expand Down
5 changes: 2 additions & 3 deletions spec/e2e/template_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ End
Describe './snyk-iac-rules template ./fixtures/custom-rules --rule test'
It 'returns passing test status'
When call ./snyk-iac-rules template ./fixtures/custom-rules --rule test
Dump
The status should be failure
The output should include 'Rule with the provided name already exists'
The stderr should be present
The output should include 'Template rules directory'
The stderr should include 'Rule with the provided name already exists'
End
End

0 comments on commit bc2df8a

Please sign in to comment.