godradis

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

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 18 Imported by: 0

README

Godradis

A full-featured library for accessing the Dradis REST API from Go programs.

Documentation

Getting Started

$ go get github.com/njfox/godradis

Then import the library for use in other Go projects. E.g.:

gd := godradis.Godradis{}
gd.Configure("https://example.com", "abcdefghijkl", false)
project, _ := gd.GetProjectByName("Example Network Penetration Test")
node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
for _, evidence := range node.Evidence {
	fmt.Printf("%v", evidence.GetField(Port))
}

Limitations

The following API endpoints have not been implemented yet:

  • Document Properties
  • Content Blocks

Additionally, the Attachments endpoint has not been thoroughly tested.

Documentation

Overview

Package godradis provides a full-featured library for accessing the Dradis server REST API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Filename string `json:"filename"`
	Link     string `json:"link"`
	Node     *Node
}

type Author

type Author struct {
	Email string `json:"email"`
}

type Client

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

type Config

type Config struct {
	BaseUrl string `json:"dradis_url"`
	ApiKey  string `json:"api_key"`
	Verify  bool   `json:"verify"`
}

type Evidence

type Evidence struct {
	Id      int                   `json:"id"`
	Content string                `json:"content"`
	Fields  orderedmap.OrderedMap `json:"fields"`
	Issue   EvidenceIssue         `json:"issue"`
	Node    *Node
}

func (*Evidence) CopyFields

func (e *Evidence) CopyFields() orderedmap.OrderedMap

func (*Evidence) GetField

func (e *Evidence) GetField(key string) (string, error)

func (*Evidence) SetField

func (e *Evidence) SetField(key, value string)

type EvidenceIssue

type EvidenceIssue struct {
	Id    int    `json:"id"`
	Title string `json:"title"`
	Url   string `json:"url"`
}

type Godradis

type Godradis struct {
	Config Config
	// contains filtered or unexported fields
}

func (*Godradis) Configure

func (gd *Godradis) Configure(url, apiKey string, verify bool)

Configure populates godradis with parameters necessary to access the Dradis server. url should be the base url of the Dradis server, before "/pro/api" and without a trailing "/" (e.g. https://example.com). apiKey is a string containing the API key shown on the user's Dradis profile page. verify instructs godradis whether to check TLS certificates on the Dradis server.

After creating the configuration, Configure creates an http.client on the Godradis object to be used for all subsequent HTTP requests to the Dradis server.

gd := godradis.Godradis{}
gd.Configure("https://example.com", "abcdefghijk", false)

func (*Godradis) CreateEvidence

func (gd *Godradis) CreateEvidence(node *Node, issue *Issue, content *orderedmap.OrderedMap) (Evidence, error)

CreateEvidence takes references to existing Node and Issue objects, and an OrderedMap object containing the content of the Evidence instance. The Evidence is attached to the node and issue on the Dradis server and a local Evidence object is returned.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
issue, _ := gd.GetIssueByTitle(&project, "Cross-Site Scripting")
content := orderedmap.New()
content.Set("Port", "443/tcp")
content.Set("Reportable", "True")
content.Set("Details", "Lorem ipsum dolor sit amet")
evidence, _ := gd.CreateEvidence(&node, &issue, content)

func (*Godradis) CreateEvidenceFromText

func (gd *Godradis) CreateEvidenceFromText(node *Node, issue *Issue, content string) (Evidence, error)

CreateEvidenceFromText provides an alternate method for creating evidence directly from a text string as opposed to the OrderedMap approach used by CreateEvidence. CreateEvidenceFromText takes references to Node and Issue objects and a string containing the raw body content and returns the newly created Evidence instance.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
issue, _ := gd.GetIssueByTitle(&project, "Cross-Site Scripting")
evidence, _ := gd.CreateEvidence(&node, &issue, "#[Port]#\r\n443/tcp\r\n\r\n#[Details]#\r\nLorem ipsum dolor\r\n\r\n")

func (*Godradis) CreateIssue

func (gd *Godradis) CreateIssue(project *Project, fields *orderedmap.OrderedMap) (Issue, error)

CreateIssue takes a reference to a Project object and an OrderedMap containing the fields in the Issue body, creates a new Issue on the server, and returns it.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
fields := orderedmap.New()
fields.Set("Title", "Insecure Password Storage")
fields.Set("Severity", "High")
fields.Set("Finding Information", "Lorem ipsum dolor sit amet")
issue, _ := gd.CreateIssue(&project, fields)

func (*Godradis) CreateIssueFromText

func (gd *Godradis) CreateIssueFromText(project *Project, text string) (Issue, error)

CreateIssueFromText provides an alternate method for creating issues directly from a text string as opposed to the OrderedMap approach used by CreateIssue. CreateIssueFromText takes a reference to a Project object and a string containing the raw body content and returns the newly created Issue.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
issue, _ = gd.CreateIssueFromText(&project, "#[Title]#\r\nInsecure Password Storage\r\n\r\n#[Severity]#\r\nHigh")

func (*Godradis) CreateIssueLibraryEntry

func (gd *Godradis) CreateIssueLibraryEntry(fields *orderedmap.OrderedMap) (IssueLibEntry, error)

func (*Godradis) CreateIssueLibraryEntryFromText

func (gd *Godradis) CreateIssueLibraryEntryFromText(content string) (IssueLibEntry, error)

func (*Godradis) CreateNode

func (gd *Godradis) CreateNode(project *Project, label string, typeId int, parentId int, position int) (Node, error)

CreateNode takes a reference to a Project object and several mandatory properties and creates a new Node on the server and returns it. label is a string representing the name of the node. typeId is an int and can be 0 (a "default" node) or 1 (a "host" node). parentId is an int indicating the ID of the parent node if there is one, otherwise it will be created as a top-level node. position is an int that determines where to insert the node within the existing node structure.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
node, _ := gd.CreateNode(&project, "127.0.0.1", 1, 14, 3)

func (*Godradis) CreateNote

func (gd *Godradis) CreateNote(node *Node, fields *orderedmap.OrderedMap, categoryId ...int) (Note, error)

CreateNote takes a reference to an existing Node object, an OrderedMap object containing the content of the Note, and an optional integer category ID that sets the note category (Defaults to "Default Category" in Dradis). The Note is attached to the node on the Dradis server and a local Note object is returned.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
fields := orderedmap.New()
fields.Set("Hostnames", "foo.com\r\nexample.foo.com")
note, _ := gd.CreateNote(&node, fields)

func (*Godradis) CreateNoteFromText

func (gd *Godradis) CreateNoteFromText(node *Node, text string, categoryId ...int) (Note, error)

CreateNoteFromText takes a reference to an existing Node object, a string containing the body of the Note, and an optional integer category ID that sets the note category (Defaults to "Default Category" in Dradis). The Note is attached to the node on the Dradis server and a local Note object is returned.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
text := "#[Hostnames]\r\nfoo.com\r\nexample.foo.com\r\n\r\n#
note, _ := gd.CreateNote(&node, text)

func (*Godradis) CreateProject

func (gd *Godradis) CreateProject(name string, clientId int, reportTemplatePropertiesId interface{}, authorIds []int, template interface{}) (Project, error)

CreateProject creates a project on the Dradis server and returns the newly created Project object. All 5 arguments are required in the function call, but only name and clientId must be non-nil. reportTemplatePropertiesId is an optional int that assigns a default report template to the project. authorIds accepts an int slice of authors to assign to the project. template is an optional string that assigns the project template based on the template name.

gd := godradis.Godradis{}

[...]

authors := [2]int[]{3, 4}
project, _ := gd.CreateProject("New Project Name", 1, nil, authors[:], nil)
fmt.Printf("%v", project.Name)

func (*Godradis) CreateTeam

func (gd *Godradis) CreateTeam(name string, teamSince ...string) (Team, error)

CreateTeam takes a name and optional teamSince (in the form "YYYY-MM-DD") string and creates a new Team on the server, returning a new Team object. teamSince defaults to the current date if it's not passed as an argument.

gd := godradis.Godradis{}

[...]

team, _ := gd.CreateTeam("New Team", "2019-01-01")
otherTeam, _ := gd.CreateTeam("Other Team")

func (*Godradis) DeleteAttachment

func (gd *Godradis) DeleteAttachment(attachment *Attachment) error

DeleteAttachment takes a reference to an existing Attachment object and deletes it from the server. The local Attachment object reference is set to nil.

func (*Godradis) DeleteEvidence

func (gd *Godradis) DeleteEvidence(evidence *Evidence) error

DeleteEvidence takes a reference to an existing Evidence object and deletes it on the server.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
evidence, _ := gd.GetEvidenceById(&node, 4)
_ := gd.DeleteEvidence(&evidence)

func (*Godradis) DeleteIssue

func (gd *Godradis) DeleteIssue(i *Issue) error

DeleteIssue takes a reference to an existing Issue object and deletes it on the server.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
issue, _ := gd.GetIssueByTitle(&project, "Cross-Site Scripting")
_ := gd.DeleteIssue(&issue)

func (*Godradis) DeleteIssueLibraryById

func (gd *Godradis) DeleteIssueLibraryById(entry IssueLibEntry) error

func (*Godradis) DeleteNode

func (gd *Godradis) DeleteNode(n *Node) error

DeleteNode takes a reference to an existing Node object and deletes it on the server.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
_ := gd.DeleteNode(&node)

func (*Godradis) DeleteNote

func (gd *Godradis) DeleteNote(note *Note) error

DeleteNote takes a reference to an existing Note object and deletes it on the server.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
note, _ := gd.GetNoteByTitle(&node, "Nmap Host Info")
_ := gd.DeleteNote(&note)

func (*Godradis) DeleteProject

func (gd *Godradis) DeleteProject(p *Project) error

DeleteProject takes a reference to a Project object and deletes the project on the Dradis server.

gd := godradis.Godradis{}

[...]

project, _ := gd.CreateProject("New Project Name", 1, nil, nil, nil)
err := gd.DeleteProject(&project)
if err != nil {
    fmt.Println(err)
}

func (*Godradis) DeleteTeam

func (gd *Godradis) DeleteTeam(t *Team) error

DeleteTeam takes a reference to a Team object and deletes the team on the server.

gd := godradis.Godradis{}

[...]

team, _ := gd.CreateTeam("New Team", "2019-01-01")
err := gd.DeleteTeam(&team)
if err != nil {
    fmt.Println(err)
}

func (*Godradis) GetAllAttachments

func (gd *Godradis) GetAllAttachments(node *Node) ([]Attachment, error)

GetAllAttachments takes a reference to an existing Node object and returns a slice of all attachments associated with that node.

func (*Godradis) GetAllEvidence

func (gd *Godradis) GetAllEvidence(node *Node) ([]Evidence, error)

GetAllEvidence takes a reference to a Node object and returns a list of all Evidence instances exist on the server for that node.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
evidences, _ := gd.GetAllEvidence(&node)

func (*Godradis) GetAllIssues

func (gd *Godradis) GetAllIssues(project *Project) ([]Issue, error)

GetAllIssues takes a reference to a Project object and returns a list of all Issues that exist on the server for that project.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
issues, _ := gd.GetAllIssues(&project)

func (*Godradis) GetAllNodes

func (gd *Godradis) GetAllNodes(project *Project) ([]Node, error)

GetAllNodes takes a reference to a Project object and returns a list of all Nodes that exist on the server for that project.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
nodes, _ := gd.GetAllNodes(&project)

func (*Godradis) GetAllNotes

func (gd *Godradis) GetAllNotes(node *Node) ([]Note, error)

GetAllNotes takes a reference to a Node object and returns a list of all Notes attached to that node on the server.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
notes, _ := gd.GetAllNotes(&node)

func (*Godradis) GetAllProjects

func (gd *Godradis) GetAllProjects() ([]Project, error)

GetAllProjects takes no arguments and retrieves a full list of all projects on the Dradis server. If an error of any kind occurs, the function will return an empty rather than partial list as well as the error.

gd := godradis.Godradis{}

[...]

projectList, _ := gd.GetAllProjects()
if len(projectList) > 0 {
    fmt.Printf("%v", projectList[0].Name)
}

func (*Godradis) GetAllTeams

func (gd *Godradis) GetAllTeams() ([]Team, error)

GetAllTeams takes no arguments and returns a list of all teams on the server.

gd := godradis.Godradis{}

[...]

teamList, _ := gd.GetAllTeams()
if len(teamList) > 0 {
    fmt.Printf("%v", teamList[0].Name)
}

func (*Godradis) GetAttachmentByName

func (gd *Godradis) GetAttachmentByName(node *Node, filename string) (Attachment, error)

GetAttachmentByName takes a reference to an existing Node object and a string filename and returns an Attachment object if it is found on the server.

func (*Godradis) GetEvidenceById

func (gd *Godradis) GetEvidenceById(node *Node, id int) (Evidence, error)

GetEvidenceById takes a reference to a Node object and int id and returns the Evidence instance associated with that id.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
evidence, _ := gd.GetEvidenceById(&node, 7)

func (*Godradis) GetIssueById

func (gd *Godradis) GetIssueById(project *Project, id int) (Issue, error)

GetIssueById takes a reference to a Project object and int id and returns the Issue associated with that id.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
issue, _ := gd.GetIssueById(&project, 12)

func (*Godradis) GetIssueByTitle

func (gd *Godradis) GetIssueByTitle(project *Project, title string) (Issue, error)

GetIssueByTitle searches for and returns an Issue object based on the title. GetIssueByTitle works by calling GetAllIssues first and then ranges over them comparing the title strings.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
issue, _ := gd.GetIssueByTitle(&project, "Cross-Site Scripting")

func (*Godradis) GetIssueLibrary

func (gd *Godradis) GetIssueLibrary() ([]IssueLibEntry, error)

func (*Godradis) GetIssueLibraryById

func (gd *Godradis) GetIssueLibraryById(id int) (IssueLibEntry, error)

func (*Godradis) GetNodeById

func (gd *Godradis) GetNodeById(project *Project, id int) (Node, error)

GetNodeById takes a reference to a Project object and int id and returns the node associated with that id.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
node, _ := gd.GetNodeById(&project, 7)

func (*Godradis) GetNodeByLabel

func (gd *Godradis) GetNodeByLabel(project *Project, label string) (Node, error)

GetNodeByLabel searches for and returns a Node object based on the label. GetNodeByLabel works by calling GetAllNodes first and then ranges over them comparing the label strings.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")

func (*Godradis) GetNoteById

func (gd *Godradis) GetNoteById(node *Node, id int) (Note, error)

GetNoteById takes a reference to a Node object and int id and returns the Note instance associated with that id.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
note, _ := gd.GetNoteById(&node, 7)

func (*Godradis) GetNoteByTitle

func (gd *Godradis) GetNoteByTitle(node *Node, title string) (Note, error)

GetNoteByTitle takes a reference to a Node object and string title and returns the first Note instance associated with that title.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
note, _ := gd.GetNoteByTitle(&node, "Nmap Host Info")

func (*Godradis) GetProjectById

func (gd *Godradis) GetProjectById(id int) (Project, error)

GetProjectById fetches a Project object from the Dradis server based on the int id.

gd := godradis.Godradis{}

[...]

project, err := gd.GetProjectById(45)
if err != nil {
    fmt.Println(err)
}

func (*Godradis) GetProjectByName

func (gd *Godradis) GetProjectByName(name string) (Project, error)

GetProjectByName searches for and returns a Project object based on the name. GetProjectByName works by calling GetAllProjects first and then ranges over them comparing the name strings.

gd := godradis.Godradis{}

[...]

project, err := gd.GetProjectByName("Foobar External Network Penetration Test")
if err != nil {
    fmt.Println(err)
}

func (*Godradis) GetTeamById

func (gd *Godradis) GetTeamById(id int) (Team, error)

GetTeamById fetches a Team object from the Dradis server based on the int id.

gd := godradis.Godradis{}

[...]

team, err := gd.GetTeamById(2)
if err != nil {
    fmt.Println(err)
}

func (*Godradis) GetTeamByName

func (gd *Godradis) GetTeamByName(name string) (Team, error)

GetTeamByName searches for and returns a Team object based on the name. GetTeamByName works by calling GetAllTeams first and then ranges over them comparing the name strings.

gd := godradis.Godradis{}

[...]

team, err := gd.GetTeamByName("Test Client")
if err != nil {
    fmt.Println(err)
}

func (*Godradis) LoadConfig

func (gd *Godradis) LoadConfig(filename string) error

LoadConfig behaves the same way as Configure except that it loads the configuration parameters from a JSON file instead of accepting them directly in the function call.

gd := godradis.Godradis{}
err := gd.LoadConfig("dradis_config.json")
if err != nil {
    fmt.Println(err)
}

func (*Godradis) UpdateEvidence

func (gd *Godradis) UpdateEvidence(evidence *Evidence, fields *orderedmap.OrderedMap, issue ...*Issue) error

UpdateEvidence takes a reference to an existing Evidence object, an OrderedMap containing the fields making up the content of the Evidence body, and optionally a reference to an Issue object if the evidence is going to be attached to a different issue on the server. UpdateEvidence updates the evidence on the server and modifies the local Evidence object in place with the updated information. Note that due to the way the Dradis API works, all fields in the body must be passed in the OrderedMap, not just the fields that are being modified.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
evidence, _ := gd.GetEvidenceById(&node, 2)
newFields := evidence.CopyFields()
newFields.Set("Port", "995/tcp")
_ := gd.UpdateEvidence(&evidence, newFields)

func (*Godradis) UpdateEvidenceFromText

func (gd *Godradis) UpdateEvidenceFromText(evidence *Evidence, content string, issue ...*Issue) error

UpdateEvidenceFromText provides an alternate method for updating evidence directly from a text string as opposed to the OrderedMap approach used by UpdateEvidence. UpdateEvidenceFromText takes a reference to an Evidence object, a string containing the content, and optionally a reference to an Issue object if the evidence is being attached to a different issue. The evidence object is modified in place with the updated information.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
evidence, _ := gd.GetEvidenceById(&node, 4)
_ := gd.UpdateEvidenceFromText(&evidence, "#[Port]#\r\n443/tcp\r\n\r\n#[Details]#\r\nLorem ipsum dolor\r\n\r\n")

func (*Godradis) UpdateIssue

func (gd *Godradis) UpdateIssue(issue *Issue, fields *orderedmap.OrderedMap) error

UpdateIssue takes a reference to an existing Issue object and an OrderedMap containing the fields making up the content of the Issue body, updates the Issue on the server, and modifies the local Issue object in place with the updated information. Note that due to the way the Dradis API works, all fields in the body must be passed in the OrderedMap, not just the fields that are being modified.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
issue, _ := gd.GetIssueByTitle(&project, "Insecure Password Storage")
fields := issue.Fields
fields.Set("Severity", "Medium")
_ := gd.UpdateIssue(&issue, fields)

func (*Godradis) UpdateIssueFromText

func (gd *Godradis) UpdateIssueFromText(issue *Issue, text string) error

UpdateIssueFromText provides an alternate method for updating issues directly from a text string as opposed to the OrderedMap approach used by UpdateIssue. UpdateIssueFromText takes a reference to an existing Issue object and a string containing the raw body content and modifies the existing Issue object in place. Note that due to the way the Dradis API works, all fields in the body must be passed in the string, not just the fields that are being modified.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
issue, _ := gd.GetIssueByTitle(&project, "Insecure Password Storage")
_ := gd.UpdateIssueFromText(&issue, "#[Title]#\r\nInsecure Password Storage\r\n\r\n#[Severity]#\r\Medium")

func (*Godradis) UpdateIssueLibraryEntry

func (gd *Godradis) UpdateIssueLibraryEntry(entry *IssueLibEntry, fields *orderedmap.OrderedMap) error

func (*Godradis) UpdateIssueLibraryEntryFromText

func (gd *Godradis) UpdateIssueLibraryEntryFromText(entry *IssueLibEntry, content string) error

func (*Godradis) UpdateNode

func (gd *Godradis) UpdateNode(n *Node, label, typeId, parentId, position interface{}) error

UpdateNode takes a reference to an existing Node object and updates any non-nil properties passed to it as arguments.

gd := godradis.Godradis{}

[...]

project, _ := gd.GetProjectByName("Foobar External Network Penetration Test")
node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
_ := gd.UpdateNode(&node, "localhost", nil, nil, nil)

func (*Godradis) UpdateNote

func (gd *Godradis) UpdateNote(note *Note, fields *orderedmap.OrderedMap, categoryId ...int) error

UpdateNote takes a reference to an existing Note object, an OrderedMap containing the fields making up the content of the Note body, and an optional integer category ID that sets the note category (Defaults to "Default Category" in Dradis). UpdateNote updates the note on the server and modifies the local Note object in place with the updated information. Note that due to the way the Dradis API works, all fields in the body must be passed in the OrderedMap, not just the fields that are being modified.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
note, _ := gd.GetNoteByTitle(&node, "Nmap Host Info")
newFields := note.CopyFields()
newFields.Set("Hostnames", "sub.foo.com")
_ := gd.UpdateNote(&note, newFields)

func (*Godradis) UpdateNoteFromText

func (gd *Godradis) UpdateNoteFromText(note *Note, text string, categoryId ...int) error

UpdateNoteFromText takes a reference to an existing Note object, a string containing the body of the Note, and an optional integer category ID that sets the note category (Defaults to "Default Category" in Dradis). UpdateNoteFromText updates the note on the server and modifies the local Note object in place with the updated information.

gd := godradis.Godradis{}

[...]

node, _ := gd.GetNodeByLabel(&project, "127.0.0.1")
note, _ := gd.GetNoteByTitle(&node, "Nmap Host Info")
text := "#[Hostnames]#\r\nsub.foo.com\r\n\r\n
note, _ := gd.UpdateNoteFromText(&node, text)

func (*Godradis) UpdateProject

func (gd *Godradis) UpdateProject(p *Project, name, clientId, reportTemplatePropertiesId interface{}, authorIds []int, template interface{}) error

UpdateProject takes a reference to an existing Project object as well as 5 arguments representing properties to update. All arguments are required to be passed to UpdateProject but only properties being modified need to be non-nil. UpdateProject modifies the original Project object in-place rather than returning a new one.

gd := godradis.Godradis{}

[...]

project, _ := gd.CreateProject("New Project Name", 1, nil, nil, nil)
err := gd.UpdateProject(&project, "Modified the project name", nil, nil, nil, nil)
if err != nil {
    fmt.Printf("%v", project.Name)
}

func (*Godradis) UpdateTeam

func (gd *Godradis) UpdateTeam(t *Team, name, teamSince interface{}) error

UpdateTeam takes a reference to an existing Team object and a name and teamSince (in the form "YYYY-MM-DD") string as optional arguments. The Team argument is updated in-place.

gd := godradis.Godradis{}

[...]

team, _ := gd.GetTeamByName("Test Client")
err := gd.UpdateTeam(&team, nil, "2019-02-01")

func (*Godradis) UploadAttachments

func (gd *Godradis) UploadAttachments(node *Node, filePath []string) ([]Attachment, error)

UploadAttachments takes a reference to an existing Node object and a slice of strings containing filepaths and uploads these attachments to the Dradis server. A slice of Attachment objects is returned.

type Issue

type Issue struct {
	Id        int                   `json:"id"`
	Title     string                `json:"title"`
	Fields    orderedmap.OrderedMap `json:"fields"`
	Text      string                `json:"text"`
	CreatedAt string                `json:"created_at"`
	UpdatedAt string                `json:"updated_at"`
	Project   *Project
}

type IssueLibEntry

type IssueLibEntry struct {
	Id        int                   `json:"id"`
	Title     string                `json:"title"`
	Fields    orderedmap.OrderedMap `json:"fields"`
	State     int                   `json:"state"`
	Content   string                `json:"content"`
	CreatedAt string                `json:"created_at"`
	UpdatedAt string                `json:"updated_at"`
}

func (*IssueLibEntry) CopyFields

func (i *IssueLibEntry) CopyFields() orderedmap.OrderedMap

func (*IssueLibEntry) GetField

func (i *IssueLibEntry) GetField(key string) (string, error)

func (*IssueLibEntry) SetField

func (i *IssueLibEntry) SetField(key, value string)

type Node

type Node struct {
	Mu        sync.Mutex
	Id        int        `json:"id"`
	Label     string     `json:"label"`
	TypeId    int        `json:"type_id"`
	ParentId  int        `json:"parent_id"`
	Position  int        `json:"position"`
	CreatedAt string     `json:"created_at"`
	UpdatedAt string     `json:"updated_at"`
	Evidence  []Evidence `json:"evidence"`
	Notes     []Note     `json:"notes"`
	Project   *Project
}

func (*Node) GetEvidenceByField

func (n *Node) GetEvidenceByField(key, value string) []*Evidence

func (*Node) GetEvidenceById

func (n *Node) GetEvidenceById(id int) (*Evidence, error)

func (*Node) GetEvidenceByIssueTitle

func (n *Node) GetEvidenceByIssueTitle(title string) []*Evidence

func (*Node) GetNoteById

func (n *Node) GetNoteById(id int) (*Note, error)

func (*Node) GetNotesByTitle

func (n *Node) GetNotesByTitle(title string) []*Note

type Note

type Note struct {
	Id         int                   `json:"id"`
	CategoryId int                   `json:"category_id"`
	Title      string                `json:"title"`
	Fields     orderedmap.OrderedMap `json:"fields"`
	Text       string                `json:"text"`
	Node       *Node
}

func (*Note) CopyFields

func (n *Note) CopyFields() orderedmap.OrderedMap

func (*Note) GetField

func (n *Note) GetField(key string) (string, error)

func (*Note) SetField

func (n *Note) SetField(key, value string)

type Owner

type Owner struct {
	Email string `json:"email"`
}

type Project

type Project struct {
	Id        int      `json:"id"`
	Name      string   `json:"name"`
	Client    Client   `json:"client"`
	CreatedAt string   `json:"created_at"`
	UpdatedAt string   `json:"updated_at"`
	Authors   []Author `json:"authors"`
	Owners    []Owner  `json:"owners"`
}

type Team

type Team struct {
	Id        int           `json:"id"`
	Name      string        `json:"name"`
	TeamSince string        `json:"client_since"` // TODO: update this if the API gets fixed (it should return "team_since")
	CreatedAt string        `json:"created_at"`
	UpdatedAt string        `json:"updated_at"`
	Projects  []TeamProject `json:"projects"`
}

type TeamProject

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

Notes

Bugs

  • The parentId argument to CreateNode may not be correctly serialized in the API request

Jump to

Keyboard shortcuts

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