This PR replaces the BishopFox jsluice dependency with a pure-Go implementation to eliminate CGO requirements and enable cross-platform compilation.
The BishopFox jsluice library requires CGO, which:
parser_nojs.go build constraints)Implemented a pure-Go JavaScript endpoint extraction engine using:
pkg/utils/jsluice.go)//go:build constraints from pkg/engine/parser/parser_generic.gopkg/engine/parser/parser_nojs.go (Windows/386 fallback no longer needed)go.mod)github.com/BishopFox/jsluice (requires CGO)github.com/ditashi/jsbeautifier-go (transitive dependency)github.com/smacker/go-tree-sitter (transitive dependency)github.com/dop251/goja (pure-Go JavaScript engine)Added comprehensive test suite (pkg/utils/jsluice_test.go):
Test Results:
$ go test ./pkg/utils/... -v
=== RUN TestExtractJsluiceEndpoints
=== RUN TestExtractJsluiceEndpoints/ES_module_with_import
=== RUN TestExtractJsluiceEndpoints/ES_module_with_export_default
=== RUN TestExtractJsluiceEndpoints/regex-only_matches_in_invalid_JS
--- PASS: TestExtractJsluiceEndpoints (0.01s)
=== RUN TestPreprocessModuleCode
--- PASS: TestPreprocessModuleCode (0.00s)
PASS
ok github.com/projectdiscovery/katana/pkg/utils 0.029s
$ go build ./...
# Successfully builds on all platforms (no CGO required)
// Handles ES6 modules that previously caused parse failures
jsCode := `import React from 'react';
const API_URL = "https://api.example.com/data";
export default function App() {
fetch(API_URL);
}`
endpoints := ExtractJsluiceEndpoints(jsCode)
// Returns: [{"https://api.example.com/data", "url"}]
Resolves #1367 /claim #1367
Akinniranye Samuel Tomiwa
@samuel-asleep
ProjectDiscovery
@projectdiscovery
Hermes1118
@dalledajay-gmail-com