Skip to content

Commit

Permalink
reduce fp nodejs runtime inspection (#2383)
Browse files Browse the repository at this point in the history
Co-authored-by: Eden Federman <[email protected]>
  • Loading branch information
AvihuHenya and edeNFed authored Feb 6, 2025
1 parent f9c2201 commit 29b06d7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions procdiscovery/pkg/inspectors/nodejs/nodejs.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package nodejs

import (
"strings"
"path/filepath"
"regexp"

"github.com/hashicorp/go-version"

Expand All @@ -11,10 +12,15 @@ import (

type NodejsInspector struct{}

const nodeProcessName = "node"
var v8Regex = regexp.MustCompile(`^(?:.*/)?node(\d+)?$`)

var nodeExecutables = map[string]bool{
"npm": true,
"yarn": true,
}

func (n *NodejsInspector) Inspect(proc *process.Details) (common.ProgrammingLanguage, bool) {
if strings.Contains(proc.ExePath, nodeProcessName) || strings.Contains(proc.CmdLine, nodeProcessName) {
if v8Regex.MatchString(filepath.Base(proc.ExePath)) || nodeExecutables[filepath.Base(proc.ExePath)] {
return common.JavascriptProgrammingLanguage, true
}

Expand Down

0 comments on commit 29b06d7

Please sign in to comment.