示例#1
0
文件: rsa.go 项目: vmware/vic
func (w *WeakKeyStrength) Match(n ast.Node, c *gas.Context) (*gas.Issue, error) {
	if node := gas.MatchCall(n, w.pattern); node != nil {
		if bits, err := gas.GetInt(node.Args[1]); err == nil && bits < (int64)(w.bits) {
			return gas.NewIssue(c, n, w.What, w.Severity, w.Confidence), nil
		}
	}
	return nil, nil
}
示例#2
0
文件: tempfiles.go 项目: vmware/vic
func (t *BadTempFile) Match(n ast.Node, c *gas.Context) (gi *gas.Issue, err error) {
	if node := gas.MatchCall(n, t.call); node != nil {
		if arg, _ := gas.GetString(node.Args[0]); t.args.MatchString(arg) {
			return gas.NewIssue(c, n, t.What, t.Severity, t.Confidence), nil
		}
	}
	return nil, nil
}
示例#3
0
文件: sql.go 项目: vmware/vic
// Looks for "fmt.Sprintf("SELECT * FROM foo where '%s', userInput)"
func (s *SqlStrFormat) Match(n ast.Node, c *gas.Context) (gi *gas.Issue, err error) {
	if node := gas.MatchCall(n, s.call); node != nil {
		if arg, _ := gas.GetString(node.Args[0]); s.pattern.MatchString(arg) {
			return gas.NewIssue(c, n, s.What, s.Severity, s.Confidence), nil
		}
	}
	return nil, nil
}
示例#4
0
文件: fileperms.go 项目: vmware/vic
func (r *FilePermissions) Match(n ast.Node, c *gas.Context) (*gas.Issue, error) {
	if node := gas.MatchCall(n, r.pattern); node != nil {
		if val, err := gas.GetInt(node.Args[1]); err == nil && val > r.mode {
			return gas.NewIssue(c, n, r.What, r.Severity, r.Confidence), nil
		}
	}
	return nil, nil
}
示例#5
0
文件: bind.go 项目: vmware/vic
func (r *BindsToAllNetworkInterfaces) Match(n ast.Node, c *gas.Context) (gi *gas.Issue, err error) {
	if node := gas.MatchCall(n, r.call); node != nil {
		if arg, err := gas.GetString(node.Args[1]); err == nil {
			if r.pattern.MatchString(arg) {
				return gas.NewIssue(c, n, r.What, r.Severity, r.Confidence), nil
			}
		}
	}
	return
}
示例#6
0
文件: rand.go 项目: vmware/vic
func (w *WeakRand) Match(n ast.Node, c *gas.Context) (*gas.Issue, error) {
	if call := gas.MatchCall(n, w.pattern); call != nil {
		for _, pkg := range c.Pkg.Imports() {
			if pkg.Name() == w.packageName && pkg.Path() == w.packagePath {
				return gas.NewIssue(c, n, w.What, w.Severity, w.Confidence), nil
			}
		}
	}
	return nil, nil
}
示例#7
0
文件: templates.go 项目: vmware/vic
func (t *TemplateCheck) Match(n ast.Node, c *gas.Context) (gi *gas.Issue, err error) {
	if node := gas.MatchCall(n, t.call); node != nil {
		for _, arg := range node.Args {
			if _, ok := arg.(*ast.BasicLit); !ok { // basic lits are safe
				return gas.NewIssue(c, n, t.What, t.Severity, t.Confidence), nil
			}
		}
	}
	return nil, nil
}
示例#8
0
文件: subproc.go 项目: vmware/vic
func (r *Subprocess) Match(n ast.Node, c *gas.Context) (*gas.Issue, error) {
	if node := gas.MatchCall(n, r.pattern); node != nil {
		for _, arg := range node.Args {
			if !gas.TryResolve(arg, c) {
				what := "Subprocess launching with variable."
				return gas.NewIssue(c, n, what, gas.High, gas.High), nil
			}
		}

		// call with partially qualified command
		if str, err := gas.GetString(node.Args[0]); err == nil {
			if !strings.HasPrefix(str, "/") {
				what := "Subprocess launching with partial path."
				return gas.NewIssue(c, n, what, gas.Medium, gas.High), nil
			}
		}

		what := "Subprocess launching should be audited."
		return gas.NewIssue(c, n, what, gas.Low, gas.High), nil
	}
	return nil, nil
}
示例#9
0
文件: unsafe.go 项目: vmware/vic
func (r *UsingUnsafe) Match(n ast.Node, c *gas.Context) (gi *gas.Issue, err error) {
	if node := gas.MatchCall(n, r.pattern); node != nil {
		return gas.NewIssue(c, n, r.What, r.Severity, r.Confidence), nil
	}
	return nil, nil
}
示例#10
0
文件: weakcrypto.go 项目: vmware/vic
func (r *UsesWeakCryptography) Match(n ast.Node, c *gas.Context) (*gas.Issue, error) {
	if node := gas.MatchCall(n, r.pattern); node != nil {
		return gas.NewIssue(c, n, r.What, r.Severity, r.Confidence), nil
	}
	return nil, nil
}