added arborist.js file & support for npm auth token for arborist lib to scan private deps

This commit is contained in:
Sahilb315
2025-04-10 01:10:56 +05:30
parent ed8f9b6d53
commit 2d2f0fdee9
6 changed files with 101 additions and 13 deletions
+11 -6
View File
@@ -11,11 +11,12 @@ import (
// ExtractorOptions holds configuration for running an extractor script
type ExtractorOptions struct {
ScriptContent string // The script content
ScriptType string // File extension like "js", "py", etc.
Interpreter string // What interpreter to use (e.g., "node", "python")
PackageName string // Name of the package to analyze
Args []string // Additional arguments to pass to the script
ScriptContent string // The script content
ScriptType string // File extension like "js", "py", etc.
Interpreter string // What interpreter to use (e.g., "node", "python")
PackageName string // Name of the package to analyze
Args []string // Additional arguments to pass to the script
Env map[string]string // Environment variables to pass to the script
}
// RunExtractor extracts an embedded script to a temp file and executes it
@@ -50,7 +51,11 @@ func RunPkgExtractor(opts ExtractorOptions) (string, error) {
// Build the command with all arguments
cmdArgs := append([]string{scriptFile.Name(), opts.PackageName, outputFile}, opts.Args...)
if err = utils.ExecCmd(interpreterPath, cmdArgs); err != nil {
var env []string
for key, value := range opts.Env {
env = append(env, fmt.Sprintf("%s=%s", key, value))
}
if err = utils.ExecCmd(interpreterPath, cmdArgs, env); err != nil {
return "", err
}
+3 -1
View File
@@ -3,11 +3,13 @@ package utils
import (
"bytes"
"fmt"
"os"
"os/exec"
)
func ExecCmd(name string, args []string) error {
func ExecCmd(name string, args, env []string) error {
cmd := exec.Command(name, args...)
cmd.Env = append(os.Environ(), env...)
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
+4
View File
@@ -9,3 +9,7 @@ func ApiKey() string {
func TenantDomain() string {
return os.Getenv("SAFEDEP_TENANT_ID")
}
func NpmAuthToken() string {
return os.Getenv("NPM_AUTH_TOKEN")
}