mirror of
https://github.com/securego/gosec.git
synced 2026-06-20 00:15:59 +02:00
* Refactor rules to utilize callListRule base structure - Introduced a new base structure `callListRule` in `rules/base.go` to standardize the implementation of rules that check for specific function calls. - Updated existing rules to inherit from `callListRule`, simplifying their structure and removing redundant ID methods. - Modified the `MetaData` field to use `RuleID` instead of `ID` for consistency across rules. - Removed the `weakcryptohash.go` and `weakdepricatedcryptohash.go` files as their functionality has been integrated into the new structure. * fix(tlsconfig): correct MetaData field name in generated TLS check * refactor: standardize rule metadata and call list initialization
21 lines
604 B
Go
21 lines
604 B
Go
package rules
|
|
|
|
import (
|
|
"go/ast"
|
|
|
|
"github.com/securego/gosec/v2"
|
|
"github.com/securego/gosec/v2/issue"
|
|
)
|
|
|
|
type sshHostKey struct {
|
|
callListRule
|
|
}
|
|
|
|
// NewSSHHostKey rule detects the use of insecure ssh HostKeyCallback.
|
|
func NewSSHHostKey(id string, _ gosec.Config) (gosec.Rule, []ast.Node) {
|
|
// This is a call list rule that checks for insecure SSH host key handling.
|
|
rule := &sshHostKey{newCallListRule(id, "Use of ssh InsecureIgnoreHostKey should be audited", issue.Medium, issue.High)}
|
|
rule.Add("golang.org/x/crypto/ssh", "InsecureIgnoreHostKey")
|
|
return rule, []ast.Node{(*ast.CallExpr)(nil)}
|
|
}
|