Skip to content

Display bug in absolute path #1084

Description

@jm-ysec

Describe the bug

When powerpipe benchmark run is invoked with --export <absolute-path>, the "File exported to" status message concatenates the process's current working directory to the export argument without first checking whether the argument is already absolute. The result is a malformed, doubled path printed to the user. The file itself is written correctly to the absolute path that was passed; only the printed message is wrong, which is misleading when scripting around the output or directing users to find their exports.

This appears to be a generic CLI-arg-to-filepath plumbing issue: --workspace, --search-path-prefix, and the benchmark identifier are not involved. The bug reproduces whenever --export is an absolute path, regardless of whether --workspace is used.

**Powerpipe version ** - Powerpipe v1.5.1

mod versions:

├── github.com/turbot/steampipe-mod-aws-compliance@v1.13.0
├── github.com/turbot/steampipe-mod-gcp-compliance@v1.3.2
└── github.com/turbot/steampipe-mod-googleworkspace-compliance@v1.0.0

To reproduce

From any powerpipe mod directory (here, ~/workspace/clients/workspace-cfg/test, which has the aws_compliance mod installed and a steampipe service running):

cd ~/workspace/clients/workspace-cfg/test

powerpipe benchmark run aws_compliance.benchmark.cis_compute_service_v100 \
  --mod-location . \
  --install-dir ./.powerpipe \
  --export /tmp/pp-bug-repro.json \
  --workspace test

Output includes:

File exported to /Users/jason/workspace/clients/workspace-cfg/test//tmp/pp-bug-repro.json

Verifying the file actually landed at the absolute path that was passed:

$ ls -la /tmp/pp-bug-repro.json
-rw-r--r--  1 jason  wheel  ...  /tmp/pp-bug-repro.json    # exists

$ ls -la "/Users/jason/workspace/clients/workspace-cfg/test//tmp/pp-bug-repro.json"
ls: ...: No such file or directory                          # the printed path does not exist

I ran a 2x2 matrix to isolate the cause:

--workspace --export Result
yes absolute (/tmp/x.json) bug<cwd>//tmp/x.json
no (--search-path-prefix aws_all) absolute (/tmp/x.json) bug<cwd>//tmp/x.json
yes relative (reports/x.json) clean — <cwd>/reports/x.json
no (--search-path-prefix aws_all) relative (reports/x.json) clean — <cwd>/reports/x.json

Bug triggers whenever --export is absolute; --workspace is not involved.

Expected behavior

File exported to /tmp/pp-bug-repro.json

The printed path should match the actual location the file was written to.

Additional context

Likely root cause: the display string is being built with something like filepath.Join(cwd, exportArg) (or string concatenation) without first checking filepath.IsAbs(exportArg). Go's filepath.Join doesn't short-circuit on absolute components, so the join always concatenates. A one-line fix along the lines of:

displayPath := exportArg
if !filepath.IsAbs(exportArg) {
    displayPath = filepath.Join(cwd, exportArg)
}

would resolve it. The file-writing path itself is clearly fine (the file lands where requested); this is purely the message-building path.

Workaround: pass --export as a path relative to cwd. For tooling that wraps powerpipe and wants a clean message, compute the relative form via filepath.Rel(cwd, absExportPath) before passing it through.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions