tfclient

package module
v0.0.0-...-a2b3b66 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2016 License: GPL-3.0 Imports: 17 Imported by: 2

README

== tfclient

tfclient is a library to communicate with ThreadFix's REST API from the Go language.  It has implemented calls to every exposed API method as documented in the https://github.com/denimgroup/threadfix/wiki/Threadfix-REST-Interface[ThreadFix REST Interface] wiki page.  Using the library you can either get the raw JSON returned by the API or populate Structs which normalize the data returned from ThreadFix into more Go-like data structures.

This code has been written and tested against the libray presented by the ThreadFix 2.1.2 Official release.

I am waiting for the release of the 2.2 version of ThreadFix before I make this "go get"-able.  Those changes will be commited shortly after 2.2 is release and I make sure the API hasn't changed on me.

Documentation

Overview

structs.go data structuctures for the ThreadFix REST API library

Package tfclient is a library for interacting with the ThreadFix REST API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppIdSearch

func AppIdSearch(s *Search, a ...int)

func CreateApplication

func CreateApplication(c *http.Client, n string, aUrl string, t int) (string, error)

func CreateClient

func CreateClient() (*http.Client, error)

func CreateEmptyConfig

func CreateEmptyConfig() error

func CreateTeam

func CreateTeam(c *http.Client, name string) (string, error)

func CreateWaf

func CreateWaf(c *http.Client, n string, wType string) (string, error)

func CweIdSearch

func CweIdSearch(s *Search, c ...int)

func EndSearch

func EndSearch(s *Search, str string)

func GetTeams

func GetTeams(c *http.Client) (string, error)

func GetWafs

func GetWafs(c *http.Client) (string, error)

func LookupAppId

func LookupAppId(c *http.Client, id int) (string, error)

func LookupAppName

func LookupAppName(c *http.Client, name string, t string) (string, error)

func LookupTeamId

func LookupTeamId(c *http.Client, id int) (string, error)

func LookupTeamName

func LookupTeamName(c *http.Client, name string) (string, error)

func LookupWafId

func LookupWafId(c *http.Client, id int) (string, error)

func LookupWafName

func LookupWafName(c *http.Client, name string) (string, error)

func MakeAppStruct

func MakeAppStruct(a *AppResp, b string) error

func MakeSearchStruct

func MakeSearchStruct(s *SrchResp, b string) error

func MakeTeamStruct

func MakeTeamStruct(t *TeamResp, b string) error

func MakeUploadStruct

func MakeUploadStruct(u *UpldResp, b string) error

func NumMergedSearch

func NumMergedSearch(s *Search, n int)

func NumSearchResults

func NumSearchResults(s *Search, n int)

func ParamSearch

func ParamSearch(s *Search, p string)

func PathSearch

func PathSearch(s *Search, p string)

func ScanUpload

func ScanUpload(c *http.Client, appId int, path string) (string, error)

func ScannerSearch

func ScannerSearch(s *Search, sc ...string)

func SetAppParams

func SetAppParams(c *http.Client, appId int, frmwrk string, rUrl string) (string, error)

func SetUrl

func SetUrl(c *http.Client, appId int, aUrl string) (string, error)

func SetWaf

func SetWaf(c *http.Client, appId int, wafId int) (string, error)

func SeveritySearch

func SeveritySearch(s *Search, sev ...int)

func ShowInSearch

func ShowInSearch(s *Search, show string)

func StartSearch

func StartSearch(s *Search, str string)

func TeamIdSearch

func TeamIdSearch(s *Search, t ...int)

func VulnSearch

func VulnSearch(c *http.Client, s *Search) (string, error)

Types

type App

type App struct {
	Id        int          `json:"id"`
	Name      string       `json:"name"`
	Url       string       `json:"url"`
	UniqId    string       `json:"uniqueId`
	NumInfo   int          `json:"infoVulnCount"`
	NumLow    int          `json:"lowVulnCount"`
	NumMed    int          `json:"mediumVulnCount"`
	NumHigh   int          `json:"highVulnCount"`
	NumCrit   int          `json:"criticalVulnCount"`
	Total     int          `json:"totalVulnCount"`
	CritLevel AppCrit      `json:"applicationCriticality"`
	Scans     map[int]Scan `json:"scans"`
	Team      TeamA        `json:"organization"`
	Waf       WafA         `json:"waf"`
}

type AppCrit

type AppCrit struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type AppResp

type AppResp struct {
	Msg      string      `json:"message"`
	Success  bool        `json:"success"`
	RespCode int         `json:"responseCode"`
	Ap       map[int]App `json:"object"`
}

type AppT

type AppT struct {
	Id        int     `json:"id"`
	Name      string  `json:"name"`
	Url       string  `json:"url"`
	CritLevel AppCrit `json:"applicationCriticality"`
}

type CWE

type CWE struct {
	Id     int    `json:"id"`
	Name   string `json:"name"`
	DispId int    `json:"displayId"`
}

type DataFlow

type DataFlow struct {
	Id      int    `json:"id"`
	LineNum int    `json:"lineNumber"`
	ColNum  int    `json:"columnNumber"`
	SrcPath string `json:"sourceFileName"`
	Line    string `json:"lineText"`
}

type DefectSt

type DefectSt struct {
	Id       int    `json:"id"`
	NativeId string `json:"nativeId"`
	Status   string `json:"status"`
	DUrl     string `json:"defectURL"`
	Image    string `json:"bugImageName"`
}

type Finding

type Finding struct {
	Id           int              `json:"id"`
	LongDesc     string           `json:"longDescription"`    // null
	AttString    string           `json:"attackString"`       // ""
	AttReq       string           `json:"attackRequest"`      // null
	AttResp      string           `json:"attackResponse"`     // null
	NativeId     string           `json:"nativeId"`           // "7a978638a89516db5aa9d74efcc9a094"
	DisplId      string           `json:"displayId"`          // null
	SrcFileLoc   string           `json:"sourceFileLocation"` // null
	DataFlows    map[int]DataFlow `json:"dataFlowElements"`   // null
	CalcUrlPath  string           `json:"calculatedUrlPath"`  // "/"
	CalcFilePath string           `json:"calculatedFilePath"` // ""
	Depend       string           `json:"dependency"`         // null,
	VulnType     string           `json:"vulnerabilityType"`  // "Web Browser XSS Protection Not Enabled"
	Severity     string           `json:"severity"`           // "1"
	Loc          SurfLoc          `json:"surfaceLocation"`
}

type MultiPara

type MultiPara struct {
	Teams    map[string]string
	Apps     map[string]string
	Cwe      map[string]string
	Scanner  map[string]string
	Severity map[string]string
}

type Result

type Result struct {
	Id           int              `json:"id"`
	Defect       DefectSt         `json:"defect"`                // null
	CalcFilePath string           `json:"calculatedFilePath"`    // null
	Active       bool             `json:"active"`                // true
	FalsPositive bool             `json:"isFalsePositive"`       // false
	Hidden       bool             `json:"hidden"`                // false
	Docs         map[int]string   `json:"documents"`             // []
	VulnComment  map[int]string   `json:"vulnerabilityComments"` // []
	Depend       string           `json:"dependency"`            // null
	Param        string           `json:"parameter"`             // null
	Path         string           `json:"path"`                  // "/"
	Apps         AppT             `json:"app"`                   // reusing AppT struct from Teams call above
	VulnId       string           `json:"vulnId"`                // "10"
	Team         TeamS            `json:"team"`                  // Abridged Team struct
	Scanners     map[int]string   `json:"channelNames"`          // Should at least have one
	Severity     Sev              `json:"genericSeverity"`       // Should have one for each finding
	CweVuln      CWE              `json:"genericVulnerability"`  // Should at least have one
	Findings     map[int]*Finding `json:"findings"`              // Should at least have one
}

type Scan

type Scan struct {
	Id         int       `json:"id"`
	TimeStamp  time.Time `json:"importTime"`
	NumClose   int       `json:"numberClosedVulnerabilities"`
	NumNew     int       `json:"numberNewVulnerabilities"`
	NumOld     int       `json:"numberOldVulnerabilities"`
	NumResurf  int       `json:"numberResurfacedVulnerabilities"`
	Total      int       `json:"numberTotalVulnerabilities"`
	NumRepeatR int       `json:"numberRepeatResults"`
	NumRepeatF int       `json:"numberRepeatFindings"`
	NumInfo    int       `json:"numberInfoVulnerabilities"`
	NumLow     int       `json:"numberLowVulnerabilities"`
	NumMed     int       `json:"numberMediumVulnerabilities"`
	NumHigh    int       `json:"numberHighVulnerabilities"`
	NumCrit    int       `json:"numberCriticalVulnerabilities"`
	ScanName   string    `json:"scannerName"`
}
type Search struct {
	ReqPara     map[string]string // Required for every request
	SingleParas SinglePara
	MultiParas  MultiPara
}

func CreateSearchStruct

func CreateSearchStruct() Search

type Sev

type Sev struct {
	Id    int    `json:"id"`
	Name  string `json:"name"`
	Value int    `json:"intValue"`
}

type SinglePara

type SinglePara struct {
	NumVulns  map[string]string
	Param     map[string]string
	Path      map[string]string
	Start     map[string]string
	End       map[string]string
	NumMerged map[string]string
}

type SrchResp

type SrchResp struct {
	Msg      string         `json:"message"`
	Success  bool           `json:"success"`
	RespCode int            `json:"responseCode"`
	Results  map[int]Result `json:"object"`
}

type SurfLoc

type SurfLoc struct {
	Id    int    `json:"id"`
	Param string `json:"parameter"` // null
	Path  string `json:"path"`      // ""
}

type Team

type Team struct {
	Id      int          `json:"id"`
	NumInfo int          `json:"infoVulnCount"`
	NumLow  int          `json:"lowVulnCount"`
	NumMed  int          `json:"mediumVulnCount"`
	NumHigh int          `json:"highVulnCount"`
	NumCrit int          `json:"criticalVulnCount"`
	Total   int          `json:"totalVulnCount"`
	Name    string       `json:"name"`
	Apps    map[int]AppT `json:applications`
}

type TeamA

type TeamA struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type TeamResp

type TeamResp struct {
	Msg      string       `json:"message"`
	Success  bool         `json:"success"`
	RespCode int          `json:"responseCode"`
	Tm       map[int]Team `json:"object"`
}

type TeamS

type TeamS struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type UpldInfo

type UpldInfo struct {
	Id            int              `json:"id"`
	ImportTime    time.Time        `json:"importTime"`
	NumClosed     int              `json:numberClosedVulnerabilities`
	NumNew        int              `json:"numberNewVulnerabilities"`
	NumOld        int              `json:"numberOldVulnerabilities"`
	NumResurf     int              `json:"numberResurfacedVulnerabilities"`
	NumTotal      int              `json:"numberTotalVulnerabilities"`
	NumRepeatRes  int              `json:"numberRepeatResults"`
	NumRepeatFind int              `json:"numberRepeatFindings"`
	NumInfo       int              `json:"numberInfoVulnerabilities"`
	NumLow        int              `json:"numberLowVulnerabilities"`
	NumMed        int              `json:"numberMediumVulnerabilities"`
	NumHigh       int              `json:"numberHighVulnerabilities"`
	NumCrit       int              `json:"numberCriticalVulnerabilities"`
	Scanner       string           `json:"scannerName"`
	Findings      map[int]*Finding `json:"findings"`
}

type UpldResp

type UpldResp struct {
	Msg      string           `json:"message"`
	Success  bool             `json:"success"`
	RespCode int              `json:"responseCode"`
	Upload   map[int]UpldInfo `json:"object"`
}

type WafA

type WafA struct {
	Id   int    `json:"id"`
	Name string `json`
}

Directories

Path Synopsis
examples
client-poc command
client-poc.go
client-poc.go

Jump to

Keyboard shortcuts

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