model

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2021 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SeverityHigh   = "HIGH"
	SeverityMedium = "MEDIUM"
	SeverityLow    = "LOW"
	SeverityInfo   = "INFO"
)

Constants to describe vulnerability's severity

Variables

Arrays to group all constants of one type

Functions

This section is empty.

Types

type Counters

type Counters struct {
	ScannedFiles           int `json:"files_scanned"`
	ParsedFiles            int `json:"files_parsed"`
	FailedToScanFiles      int `json:"files_failed_to_scan"`
	TotalQueries           int `json:"queries_total"`
	FailedToExecuteQueries int `json:"queries_failed_to_execute"`
	FailedSimilarityID     int `json:"queries_failed_to_compute_similarity_id"`
}

Counters hold information about how many files were scanned, parsed, failed to be scaned, the total of queries and how many queries failed to execute

type Document

type Document map[string]interface{}

func (Document) MarshalEasyJSON

func (v Document) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Document) MarshalJSON

func (v Document) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Document) UnmarshalEasyJSON

func (v *Document) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Document) UnmarshalJSON

func (v *Document) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Documents

type Documents struct {
	Documents []Document `json:"document"`
}

func (Documents) MarshalEasyJSON

func (v Documents) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Documents) MarshalJSON

func (v Documents) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Documents) UnmarshalEasyJSON

func (v *Documents) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Documents) UnmarshalJSON

func (v *Documents) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Extensions

type Extensions map[string]struct{}

Extensions represents a list of supported extensions

func (Extensions) Include

func (e Extensions) Include(ext string) bool

Include returns true if an extension is included in supported extensions listed otherwise returns false

func (Extensions) MatchedFilesRegex

func (e Extensions) MatchedFilesRegex() string

MatchedFilesRegex returns the regex rule to identify if an extension is supported or not

type FileKind

type FileKind string

FileKind is the extension of a file

const (
	KindTerraform FileKind = "TF"
	KindJSON      FileKind = "JSON"
	KindYAML      FileKind = "YAML"
	KindDOCKER    FileKind = "DOCKERFILE"
	KindCOMMON    FileKind = "*"
)

Constants to describe what kind of file refers

type FileMetadata

type FileMetadata struct {
	ID           string `db:"id"`
	ScanID       string `db:"scan_id"`
	Document     Document
	OriginalData string   `db:"orig_data"`
	Kind         FileKind `db:"kind"`
	FileName     string   `db:"file_name"`
}

FileMetadata is a representation of basic information and content of a file

type FileMetadatas

type FileMetadatas []FileMetadata

FileMetadatas is a slice of FileMetadata

func (FileMetadatas) Combine

func (m FileMetadatas) Combine() Documents

Combine merge documents from FileMetadatas using the ID as reference for Document ID and FileName as reference for file

func (FileMetadatas) ToMap

func (m FileMetadatas) ToMap() map[string]FileMetadata

ToMap creates a map of FileMetadatas, which the key is the FileMedata ID and the value is the FileMetadata

type IssueType

type IssueType string

IssueType is the issue's type string representation

const (
	IssueTypeMissingAttribute   IssueType = "MissingAttribute"
	IssueTypeRedundantAttribute IssueType = "RedundantAttribute"
	IssueTypeIncorrectValue     IssueType = "IncorrectValue"
)

Constants to describe issue's type

type QueryConfig added in v1.1.2

type QueryConfig struct {
	FileKind FileKind
	Platform string
}

QueryConfig is a struct that contains the fileKind and platform of the rego query

type QueryMetadata

type QueryMetadata struct {
	Query    string
	Content  string
	Metadata map[string]interface{}
	Platform string
}

QueryMetadata is a representation of general information about a query

type Severity

type Severity string

Severity of the vulnerability

type SeveritySummary

type SeveritySummary struct {
	ScanID           string           `json:"scan_id"`
	SeverityCounters map[Severity]int `json:"severity_counters"`
	TotalCounter     int              `json:"total_counter"`
}

SeveritySummary contains scans' result numbers, how many vulnerabilities of each severity was detected

type Summary

type Summary struct {
	Counters
	Queries []VulnerableQuery `json:"queries"`
	SeveritySummary
}

Summary is a report of a single scan

func CreateSummary

func CreateSummary(counters Counters, vulnerabilities []Vulnerability, scanID string) Summary

CreateSummary creates a report for a single scan, based on its scanID

type Vulnerability

type Vulnerability struct {
	ID               int       `json:"id"`
	ScanID           string    `db:"scan_id" json:"-"`
	SimilarityID     string    `db:"similarity_id" json:"similarityID"`
	FileID           string    `db:"file_id" json:"-"`
	FileName         string    `db:"file_name" json:"fileName"`
	QueryID          string    `db:"query_id" json:"queryID"`
	QueryName        string    `db:"query_name" json:"queryName"`
	Platform         string    `db:"platform" json:"platform"`
	Severity         Severity  `json:"severity"`
	Line             int       `json:"line"`
	IssueType        IssueType `db:"issue_type" json:"issueType"`
	SearchKey        string    `db:"search_key" json:"searchKey"`
	SearchValue      string    `db:"search_value" json:"searchValue"`
	KeyExpectedValue string    `db:"key_expected_value" json:"expectedValue"`
	KeyActualValue   string    `db:"key_actual_value" json:"actualValue"`
	Value            *string   `db:"value" json:"value"`
	Output           string    `json:"-"`
}

Vulnerability is a representation of a detected vulnerability in scanned files after running a query

type VulnerableFile

type VulnerableFile struct {
	FileName         string    `json:"file_name"`
	SimilarityID     string    `json:"similarity_id"`
	Line             int       `json:"line"`
	IssueType        IssueType `json:"issue_type"`
	SearchKey        string    `json:"search_key"`
	SearchValue      string    `json:"search_value"`
	KeyExpectedValue string    `json:"expected_value"`
	KeyActualValue   string    `json:"actual_value"`
	Value            *string   `json:"value"`
}

VulnerableFile contains information of a vulnerable file and where the vulnerability was found

type VulnerableQuery

type VulnerableQuery struct {
	QueryName string           `json:"query_name"`
	QueryID   string           `json:"query_id"`
	Severity  Severity         `json:"severity"`
	Platform  string           `json:"platform"`
	Files     []VulnerableFile `json:"files"`
}

VulnerableQuery contains a query that tested positive ID, name, severity and a list of files that tested vulnerable

Jump to

Keyboard shortcuts

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