core

package
v0.0.0-...-37205e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

(c) Copyright 2016 Hewlett Packard Enterprise Development LP

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetChar

func GetChar(n ast.Node) (byte, error)

func GetFloat

func GetFloat(n ast.Node) (float64, error)

func GetInt

func GetInt(n ast.Node) (int64, error)

func GetString

func GetString(n ast.Node) (string, error)

func MatchCall

func MatchCall(n ast.Node, r *regexp.Regexp) *ast.CallExpr

func MatchCompLit

func MatchCompLit(n ast.Node, r *regexp.Regexp) *ast.CompositeLit

func Select

func Select(s Selector, n ast.Node, bits ...reflect.Type)

func SimpleSelect

func SimpleSelect(n ast.Node, bits ...reflect.Type) ast.Node

func TryResolve

func TryResolve(n ast.Node, c *Context) bool

Types

type Analyzer

type Analyzer struct {
	Issues []Issue `json:"issues"`
	Stats  Metrics `json:"metrics"`
	// contains filtered or unexported fields
}

func NewAnalyzer

func NewAnalyzer(conf map[string]interface{}, logger *log.Logger) Analyzer

func (*Analyzer) AddRule

func (gas *Analyzer) AddRule(r Rule, n ast.Node)

func (*Analyzer) Ignore

func (gas *Analyzer) Ignore(n ast.Node) bool

func (*Analyzer) Process

func (gas *Analyzer) Process(filename string) error

func (*Analyzer) ProcessSource

func (gas *Analyzer) ProcessSource(filename string, source string) error

func (*Analyzer) Visit

func (gas *Analyzer) Visit(n ast.Node) ast.Visitor

type Context

type Context struct {
	FileSet  *token.FileSet
	Comments ast.CommentMap
	Info     *types.Info
	Pkg      *types.Package
	Root     *ast.File
	Config   map[string]interface{}
}

type Issue

type Issue struct {
	Severity   Score  `json:"severity"`
	Confidence Score  `json:"confidence"`
	What       string `json:"details"`
	File       string `json:"file"`
	Code       string `json:"code"`
	Line       int    `json:"line"`
}

func NewIssue

func NewIssue(ctx *Context, node ast.Node, desc string, severity Score, confidence Score) *Issue

type MetaData

type MetaData struct {
	Severity   Score
	Confidence Score
	What       string
}

type Metrics

type Metrics struct {
	NumFiles int `json:"files"`
	NumLines int `json:"lines"`
	NumNosec int `json:"nosec"`
	NumFound int `json:"found"`
}

type Rule

type Rule interface {
	Match(ast.Node, *Context) (*Issue, error)
}

type RuleSet

type RuleSet map[reflect.Type][]Rule

type Score

type Score int
const (
	Low Score = iota
	Medium
	High
)

func (Score) MarshalJSON

func (c Score) MarshalJSON() ([]byte, error)

func (Score) String

func (c Score) String() string

type SelectFunc

type SelectFunc func(ast.Node, int) bool

A selector function. This is like a visitor, but has a richer interface. It is called with the current ast.Node being visitied and that nodes depth in the tree. The function can return true to continue traversing the tree, or false to end traversal here.

type Selector

type Selector interface {
	Final(ast.Node)
	Partial(ast.Node) bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL