Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

globals => shared struct #5311

Draft
wants to merge 9 commits into
base: dev
Choose a base branch
from
Draft

globals => shared struct #5311

wants to merge 9 commits into from

Conversation

Mzack9999
Copy link
Member

Proposed changes

Closes #5239

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@tarunKoyalwar
Copy link
Member

sharing some thoughts about removing global dialer from javascript protocols

i think the challenging part would be to remove global dialer references from javascript modules at js/libs from my research on this it seems there are two ways

  • fork goja and add context support to .Run and expose it as first argument of any/all functions/methods ( ex: currently in goja, when first argument of function is set to runtime instance (

    // NewBuffer creates a new buffer from a byte slice.
    func NewBuffer(call goja.ConstructorCall, runtime *goja.Runtime) *goja.Object {
    if len(call.Arguments) > 0 {
    if arg, ok := call.Argument(0).Export().([]byte); ok {
    return utils.LinkConstructor(call, runtime, &Buffer{buf: arg})
    } else {
    utils.NewNucleiJS(runtime).Throw("Invalid argument type. Expected bytes/Uint8Array as input but got %T", call.Argument(0).Export())
    }
    }
    return utils.LinkConstructor(call, runtime, &Buffer{})
    }
    ) , the current runtime used in exposed/shared here. in similar way we can add support for context.Context, this will be helpful to pass dialer instance with context.Value as well as context support in javascript protocol ( which is not supported yet, we have global runtime timeout but that's not the same thing i guess)

  • another way i can think is similar to ^ but instead of fork and updating core, we can use code generation while generating bindings ( https://github.com/projectdiscovery/nuclei/blob/dev/pkg/js/generated/go/libbytes/bytes.go)

imo i think more scalable + easier approach would be 1) because it will improve other components as well ( ex: flow , pre-condition etc )

cc: @Mzack9999 , @Ice3man543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

remove global singletons
2 participants