Skip to content

Commit

Permalink
fix(arm): use correct type casting for ints in azure scan (#1376)
Browse files Browse the repository at this point in the history
* fix(arm): use correct type casting for ints in azure scan

* add test
  • Loading branch information
nikpivkin committed Jul 20, 2023
1 parent 9046b67 commit 20ba844
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/scanners/azure/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (v Value) AsInt() int {
if v.Kind != KindNumber {
return 0
}
return int(v.rLit.(float64))
return int(v.rLit.(int64))
}

func (v Value) AsFloat() float64 {
Expand Down
13 changes: 13 additions & 0 deletions pkg/scanners/azure/value_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package azure

import (
"testing"

"github.com/aquasecurity/defsec/pkg/types"
"github.com/stretchr/testify/assert"
)

func Test_ValueAsInt(t *testing.T) {
val := NewValue(int64(10), types.NewTestMetadata())
assert.Equal(t, 10, val.AsInt())
}

0 comments on commit 20ba844

Please sign in to comment.