mirror of
https://github.com/securego/gosec.git
synced 2025-11-23 22:15:04 +02:00
Handle the ValueSpec when trying to resolve an AST tree node
Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
committed by
Cosmin Cojocar
parent
c1970ff5c9
commit
f413f1436d
@@ -73,7 +73,7 @@ func resolveCallExpr(n *ast.CallExpr, c *Context) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TryResolve will attempt, given a subtree starting at some ATS node, to resolve
|
// TryResolve will attempt, given a subtree starting at some AST node, to resolve
|
||||||
// all values contained within to a known constant. It is used to check for any
|
// all values contained within to a known constant. It is used to check for any
|
||||||
// unknown values in compound expressions.
|
// unknown values in compound expressions.
|
||||||
func TryResolve(n ast.Node, c *Context) bool {
|
func TryResolve(n ast.Node, c *Context) bool {
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ var _ = Describe("Resolve ast node to concrete value", func() {
|
|||||||
Expect(target).ShouldNot(BeNil())
|
Expect(target).ShouldNot(BeNil())
|
||||||
Expect(gosec.TryResolve(target, ctx)).Should(BeTrue())
|
Expect(gosec.TryResolve(target, ctx)).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should successfully resolve value spec", func() {
|
It("should successfully resolve value spec", func() {
|
||||||
var value *ast.ValueSpec
|
var value *ast.ValueSpec
|
||||||
pkg := testutils.NewTestPackage()
|
pkg := testutils.NewTestPackage()
|
||||||
@@ -111,7 +112,6 @@ var _ = Describe("Resolve ast node to concrete value", func() {
|
|||||||
Expect(value).ShouldNot(BeNil())
|
Expect(value).ShouldNot(BeNil())
|
||||||
Expect(gosec.TryResolve(value, ctx)).Should(BeTrue())
|
Expect(gosec.TryResolve(value, ctx)).Should(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user