diff options
| author | Shulhan <ms@kilabit.info> | 2021-03-21 18:34:30 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-03-21 18:34:30 +0700 |
| commit | 5828835bcd18eff070789fd82401480c244bbc27 (patch) | |
| tree | 0b030e1f037684a9f5e81d62d8db52dd6ce69532 /http_target.go | |
| parent | ab00b51a1353c7f17697e027061b4c20509a7a80 (diff) | |
| download | gorankusu-5828835bcd18eff070789fd82401480c244bbc27.tar.xz | |
all: load pass attack results and implement function to get attack result
When the service started, it will load all previous attack results
from directory Environment.ResultsDir.
It will only scan the file name and append it to HttpTarget.Results
due to the size and time to load one of them can take time.
Through the web interface, user can click "Show" button to load
the result and display it on the screen.
Diffstat (limited to 'http_target.go')
| -rw-r--r-- | http_target.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/http_target.go b/http_target.go index 24603ca..03c05b1 100644 --- a/http_target.go +++ b/http_target.go @@ -5,7 +5,7 @@ package trunks import ( - "fmt" + "path/filepath" "sync" libhttp "github.com/shuLhan/share/lib/http" @@ -89,18 +89,23 @@ func (ht *HttpTarget) deleteResult(result *AttackResult) { ht.Results = ht.Results[:len(ht.Results)-1] } -func (ht *HttpTarget) addResult(path, name string) (err error) { +func (ht *HttpTarget) addResult(dir, name string) (err error) { ar := &AttackResult{ - TargetID: ht.ID, - Name: name, - } - - err = ar.init(path) - if err != nil { - return fmt.Errorf("HttpTarget.addResult: %s %s: %w", path, name, err) + HttpTargetID: ht.ID, + Name: name, + fullpath: filepath.Join(dir, name), } ht.Results = append(ht.Results, ar) return nil } + +func (ht *HttpTarget) getResultByName(name string) (result *AttackResult) { + for _, result = range ht.Results { + if result.Name == name { + return result + } + } + return nil +} |
