mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 21:35:26 +00:00
Added response truncation support with flags (#2688)
* Added response truncation support with flags * Fixed failing tests for no size
This commit is contained in:
parent
3ebd1f689b
commit
9944f5e94e
@ -194,6 +194,8 @@ on extensive configurability, massive extensibility and ease of use.`)
|
|||||||
flagSet.StringVarP(&options.Interface, "interface", "i", "", "network interface to use for network scan"),
|
flagSet.StringVarP(&options.Interface, "interface", "i", "", "network interface to use for network scan"),
|
||||||
flagSet.StringVarP(&options.SourceIP, "source-ip", "sip", "", "source ip address to use for network scan"),
|
flagSet.StringVarP(&options.SourceIP, "source-ip", "sip", "", "source ip address to use for network scan"),
|
||||||
flagSet.StringVar(&options.CustomConfigDir, "config-directory", "", "Override the default config path ($home/.config)"),
|
flagSet.StringVar(&options.CustomConfigDir, "config-directory", "", "Override the default config path ($home/.config)"),
|
||||||
|
flagSet.IntVarP(&options.ResponseReadSize, "response-size-read", "rsr", 10*1024*1024, "max response size to read in bytes"),
|
||||||
|
flagSet.IntVarP(&options.ResponseSaveSize, "response-size-save", "rss", 1*1024*1024, "max response size to read in bytes"),
|
||||||
)
|
)
|
||||||
|
|
||||||
flagSet.CreateGroup("interactsh", "interactsh",
|
flagSet.CreateGroup("interactsh", "interactsh",
|
||||||
|
|||||||
@ -158,8 +158,16 @@ func (request *Request) MakeResultEventItem(wrapped *output.InternalWrappedEvent
|
|||||||
MatcherStatus: true,
|
MatcherStatus: true,
|
||||||
IP: types.ToString(wrapped.InternalEvent["ip"]),
|
IP: types.ToString(wrapped.InternalEvent["ip"]),
|
||||||
Request: types.ToString(wrapped.InternalEvent["request"]),
|
Request: types.ToString(wrapped.InternalEvent["request"]),
|
||||||
Response: types.ToString(wrapped.InternalEvent["response"]),
|
Response: request.truncateResponse(wrapped.InternalEvent["response"]),
|
||||||
CURLCommand: types.ToString(wrapped.InternalEvent["curl-command"]),
|
CURLCommand: types.ToString(wrapped.InternalEvent["curl-command"]),
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (request *Request) truncateResponse(response interface{}) string {
|
||||||
|
responseString := types.ToString(response)
|
||||||
|
if len(responseString) > request.options.Options.ResponseSaveSize {
|
||||||
|
return responseString[:request.options.Options.ResponseSaveSize]
|
||||||
|
}
|
||||||
|
return responseString
|
||||||
|
}
|
||||||
|
|||||||
@ -538,6 +538,8 @@ func (request *Request) executeRequest(input *contextargs.Context, generatedRequ
|
|||||||
var bodyReader io.Reader
|
var bodyReader io.Reader
|
||||||
if request.MaxSize != 0 {
|
if request.MaxSize != 0 {
|
||||||
bodyReader = io.LimitReader(resp.Body, int64(request.MaxSize))
|
bodyReader = io.LimitReader(resp.Body, int64(request.MaxSize))
|
||||||
|
} else if request.options.Options.ResponseReadSize != 0 {
|
||||||
|
bodyReader = io.LimitReader(resp.Body, int64(request.options.Options.ResponseReadSize))
|
||||||
} else {
|
} else {
|
||||||
bodyReader = resp.Body
|
bodyReader = resp.Body
|
||||||
}
|
}
|
||||||
|
|||||||
@ -244,6 +244,10 @@ type Options struct {
|
|||||||
Interface string
|
Interface string
|
||||||
// SourceIP sets custom source IP address for network requests
|
// SourceIP sets custom source IP address for network requests
|
||||||
SourceIP string
|
SourceIP string
|
||||||
|
// ResponseReadSize is the maximum size of response to read
|
||||||
|
ResponseReadSize int
|
||||||
|
// ResponseSaveSize is the maximum size of response to save
|
||||||
|
ResponseSaveSize int
|
||||||
// Health Check
|
// Health Check
|
||||||
HealthCheck bool
|
HealthCheck bool
|
||||||
// Time to wait between each input read operation before closing the stream
|
// Time to wait between each input read operation before closing the stream
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user