{"record":{"id":"f265bb3744af27cf","repo":"slimtoolkit/slim","slug":"file-path-is-not-absolute","errorCode":null,"errorMessage":"file path is not absolute","messagePattern":"file path is not absolute","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/inspector/sodeps/sodeps.go","lineNumber":18,"sourceCode":"package sodeps\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/slimtoolkit/slim/pkg/app/sensor/detector/binfile\"\n\n\tlog \"github.com/sirupsen/logrus\"\n)\n\n// Inspector errors\nvar (\n\tErrFilePathNotAbs      = errors.New(\"file path is not absolute\")\n\tErrFileNotBin          = errors.New(\"file is not a binary\")\n\tErrDepResolverNotFound = errors.New(\"dependency resolver not found\")\n)\n\nconst (\n\tresolverExeName = \"ldd\"\n)\n\nfunc AllExeDependencies(exeFileName string, find bool) ([]string, error) {\n\tif !strings.HasPrefix(exeFileName, \"/\") {\n\t\tif !find {\n\t\t\treturn nil, ErrFilePathNotAbs\n\t\t}\n\n\t\texePath, err := exec.LookPath(exeFileName)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/inspector/sodeps/sodeps.go#L1-L36","documentation":"ErrFilePathNotAbs is a sentinel error returned by sodeps.AllExeDependencies and AllDependencies when the given file path is not an absolute path (no leading '/'). The shared-library dependency inspector needs a concrete in-image path to run ldd against.","triggerScenarios":"Calling AllDependencies with a relative path like 'bin/app'; calling AllExeDependencies with a relative name and find=false (so no PATH lookup is performed).","commonSituations":"Passing a path from relative Dockerfile WORKDIR context; passing a bare executable name while expecting implicit PATH resolution without enabling the find option.","solutions":["Pass an absolute path (e.g., /usr/local/bin/app) to AllDependencies","For AllExeDependencies, pass find=true so the executable is resolved via exec.LookPath, or absolutize the path yourself","Join relative inputs with the container's working directory before calling"],"exampleFix":"// before\ndeps, err := sodeps.AllDependencies(\"bin/app\")\n// after\ndeps, err := sodeps.AllDependencies(\"/usr/local/bin/app\")","handlingStrategy":"validation","validationCode":"// Go: check absolute path before calling\nif !filepath.IsAbs(binPath) {\n    return fmt.Errorf(\"path must be absolute: %s\", binPath)\n}\ndeps, err := sodeps.AllDependencies(binPath)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Absolutize all input paths with filepath.Abs or resolve against the container root","Use AllExeDependencies with find=true for bare executable names","Sanitize user-supplied paths early in your pipeline"],"tags":["validation","paths","dependency-inspection","go"],"backgroundTag":"path-not-absolute","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}