Skip to content

Commit

Permalink
Modified storing of response chains, because it was not correct
Browse files Browse the repository at this point in the history
  • Loading branch information
skraxberger committed Aug 30, 2023
1 parent d463b3b commit 13f78bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 7 additions & 3 deletions common/httpx/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ func (r *Response) GetChainStatusCodes() []int {
// GetChain dump the whole redirect chain as string
func (r *Response) GetChain() string {
var respchain strings.Builder
for _, chainItem := range r.Chain {
respchain.Write(chainItem.Request)
respchain.Write(chainItem.Response)
for counter, chainItem := range r.Chain {
if counter != 0 {
respchain.Write(chainItem.Request)
}
if counter < len(r.Chain)-1 {
respchain.Write(chainItem.Response)
}
}
return respchain.String()
}
Expand Down
6 changes: 5 additions & 1 deletion runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1794,14 +1794,18 @@ retry:
respRaw = respRaw[:scanopts.MaxResponseBodySizeToSave]
}
data := append([]byte(fullURL), append([]byte("\n\n"), reqRaw...)...)
if scanopts.StoreChain && resp.HasChain() {
resp.GetChain()
data = append(data, append([]byte("\n"), []byte(resp.GetChain())...)...)
}
data = append(data, append([]byte("\n"), respRaw...)...)
_ = fileutil.CreateFolder(responseBaseDir)
writeErr := os.WriteFile(responsePath, data, 0644)
if writeErr != nil {
gologger.Error().Msgf("Could not write response at path '%s', to disk: %s", responsePath, writeErr)
}
if scanopts.StoreChain && resp.HasChain() {
writeErr := os.WriteFile(responsePath, []byte(resp.GetChain()), 0644)
//writeErr := os.WriteFile(responsePath, []byte(resp.GetChain()), 0644)
if writeErr != nil {
gologger.Warning().Msgf("Could not write response at path '%s', to disk: %s", responsePath, writeErr)
}
Expand Down

0 comments on commit 13f78bc

Please sign in to comment.