reverse logic

This commit is contained in:
Mzack9999
2025-04-02 20:01:09 +02:00
parent ad67e70a25
commit f886c404e9
5 changed files with 26 additions and 20 deletions
+2 -1
View File
@@ -12,4 +12,5 @@ cmd/functional-test/*.cfg
.devcontainer
/httpx
/dist
/resume.cfg
/resume.cfg
vendor/
+1
View File
@@ -129,6 +129,7 @@ HEADLESS:
-system-chrome enable using local installed chrome for screenshot
-ho, -headless-options string[] start headless chrome with additional options
-esb, -exclude-screenshot-bytes enable excluding screenshot bytes from json output
-no-screenshot-full-page disable saving full page screenshot
-ehb, -exclude-headless-body enable excluding headless header from json output
-sfp, -screenshot-full-page enable saving full page screenshot
-st, -screenshot-timeout value set timeout for screenshot in seconds (default 10s)
+1 -1
View File
@@ -99,7 +99,7 @@ func NewBrowser(proxy string, useLocal bool, optionalArgs map[string]string) (*B
return engine, nil
}
func (b *Browser) ScreenshotWithBody(url string, fullPage bool, timeout time.Duration, idle time.Duration, headers []string) ([]byte, string, error) {
func (b *Browser) ScreenshotWithBody(url string, timeout time.Duration, idle time.Duration, headers []string, fullPage bool) ([]byte, string, error) {
page, err := b.engine.Page(proto.TargetCreateTarget{})
if err != nil {
return nil, "", err
+20 -16
View File
@@ -104,11 +104,15 @@ type ScanOptions struct {
DisableStdin bool
NoScreenshotBytes bool
NoHeadlessBody bool
ScreenshotFullPage bool
NoScreenshotFullPage bool
ScreenshotTimeout time.Duration
ScreenshotIdle time.Duration
}
func (s *ScanOptions) IsScreenshotFullPage() bool {
return !s.NoScreenshotFullPage
}
func (s *ScanOptions) Clone() *ScanOptions {
return &ScanOptions{
Methods: s.Methods,
@@ -159,7 +163,7 @@ func (s *ScanOptions) Clone() *ScanOptions {
UseInstalledChrome: s.UseInstalledChrome,
NoScreenshotBytes: s.NoScreenshotBytes,
NoHeadlessBody: s.NoHeadlessBody,
ScreenshotFullPage: s.ScreenshotFullPage,
NoScreenshotFullPage: s.NoScreenshotFullPage,
ScreenshotTimeout: s.ScreenshotTimeout,
ScreenshotIdle: s.ScreenshotIdle,
}
@@ -307,19 +311,19 @@ type Options struct {
OutputMatchCondition string
StripFilter string
//The OnResult callback function is invoked for each result. It is important to check for errors in the result before using Result.Err.
OnResult OnResultCallback
DisableUpdateCheck bool
NoDecode bool
Screenshot bool
UseInstalledChrome bool
TlsImpersonate bool
DisableStdin bool
HttpApiEndpoint string
NoScreenshotBytes bool
NoHeadlessBody bool
ScreenshotFullPage bool
ScreenshotTimeout time.Duration
ScreenshotIdle time.Duration
OnResult OnResultCallback
DisableUpdateCheck bool
NoDecode bool
Screenshot bool
UseInstalledChrome bool
TlsImpersonate bool
DisableStdin bool
HttpApiEndpoint string
NoScreenshotBytes bool
NoHeadlessBody bool
NoScreenshotFullPage bool
ScreenshotTimeout time.Duration
ScreenshotIdle time.Duration
// HeadlessOptionalArguments specifies optional arguments to pass to Chrome
HeadlessOptionalArguments goflags.StringSlice
Protocol string
@@ -391,7 +395,7 @@ func ParseOptions() *Options {
flagSet.StringSliceVarP(&options.HeadlessOptionalArguments, "headless-options", "ho", nil, "start headless chrome with additional options", goflags.FileCommaSeparatedStringSliceOptions),
flagSet.BoolVarP(&options.NoScreenshotBytes, "exclude-screenshot-bytes", "esb", false, "enable excluding screenshot bytes from json output"),
flagSet.BoolVarP(&options.NoHeadlessBody, "exclude-headless-body", "ehb", false, "enable excluding headless header from json output"),
flagSet.BoolVarP(&options.ScreenshotFullPage, "screenshot-full-page", "sfp", true, "enable saving full page screenshot"),
flagSet.BoolVar(&options.NoScreenshotFullPage, "no-screenshot-full-page", false, "disable saving full page screenshot"),
flagSet.DurationVarP(&options.ScreenshotTimeout, "screenshot-timeout", "st", 10*time.Second, "set timeout for screenshot in seconds"),
flagSet.DurationVarP(&options.ScreenshotIdle, "screenshot-idle", "sid", 1*time.Second, "set idle time before taking screenshot in seconds"),
)
+2 -2
View File
@@ -296,7 +296,7 @@ func New(options *Options) (*Runner, error) {
scanopts.Screenshot = options.Screenshot
scanopts.NoScreenshotBytes = options.NoScreenshotBytes
scanopts.NoHeadlessBody = options.NoHeadlessBody
scanopts.ScreenshotFullPage = options.ScreenshotFullPage
scanopts.NoScreenshotFullPage = options.NoScreenshotFullPage
scanopts.UseInstalledChrome = options.UseInstalledChrome
scanopts.ScreenshotTimeout = options.ScreenshotTimeout
scanopts.ScreenshotIdle = options.ScreenshotIdle
@@ -2188,7 +2188,7 @@ retry:
var pHash uint64
if scanopts.Screenshot {
var err error
screenshotBytes, headlessBody, err = r.browser.ScreenshotWithBody(fullURL, scanopts.ScreenshotFullPage, scanopts.ScreenshotTimeout, scanopts.ScreenshotIdle, r.options.CustomHeaders)
screenshotBytes, headlessBody, err = r.browser.ScreenshotWithBody(fullURL, scanopts.ScreenshotTimeout, scanopts.ScreenshotIdle, r.options.CustomHeaders, scanopts.IsScreenshotFullPage())
if err != nil {
gologger.Warning().Msgf("Could not take screenshot '%s': %s", fullURL, err)
} else {