Skip to content

Commit

Permalink
CR: make map access and cast safe in rails detector
Browse files Browse the repository at this point in the history
  • Loading branch information
Yumasi committed Oct 22, 2024
1 parent c87d97e commit d18d420
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/collector/corechecks/servicediscovery/usm/ruby.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ func newRailsDetector(ctx DetectionContext) detector {
// project is created. This file should contain a `module` declaration with the
// application name.
func (r railsDetector) detect(_ []string) (ServiceMetadata, bool) {
proc := r.ctx.contextMap[ServiceProc].(*process.Process)
var proc *process.Process

if procEntry, ok := r.ctx.ContextMap[ServiceProc]; ok {
if p, ok := procEntry.(*process.Process); ok {
proc = p
} else {
log.Error("could not get process object in rails detector")
}
}

cwd, err := proc.Cwd()
if err != nil {
log.Debugf("could not get cwd of process: %s", err)
Expand Down

0 comments on commit d18d420

Please sign in to comment.