Container scanner image 6.6.0 is failing to get relative path
### Summary One of our [customers](https://gitlab.zendesk.com/agent/tickets/483185) (internal) reported that container scanning is no longer working. The main error is: ``` [ERROR] [2023-12-21 07:43:05 +0000] [container-scanning] > different prefix: "" and "/builds/SNIPPED/SNIPPED" [ERROR] [2023-12-21 07:43:05 +0000] [container-scanning] > /usr/local/lib/ruby/3.1.0/pathname.rb:528:in `relative_path_from' /usr/local/bundle/gems/gcs-6.6.0/ee/lib/gcs/remediations/remediation.rb:112:in `diff_to_patch' /usr/local/bundle/gems/gcs-6.6.0/ee/lib/gcs/remediations/remediation.rb:104:in `create_patch' /usr/local/bundle/gems/gcs-6.6.0/ee/lib/gcs/remediations/remediation.rb:79:in `to_hash' /usr/local/bundle/gems/gcs-6.6.0/ee/lib/gcs/remediations/collection.rb:19:in `map' /usr/local/bundle/gems/gcs-6.6.0/ee/lib/gcs/remediations/collection.rb:19:in `to_hash' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/converter.rb:40:in `convert' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/plugin/container_scan.rb:10:in `convert' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/scan.rb:26:in `scan_image' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/cli.rb:16:in `block in scan' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/cli.rb:15:in `map' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/cli.rb:15:in `scan' /usr/local/bundle/gems/thor-1.3.0/lib/thor/command.rb:28:in `run' /usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command' /usr/local/bundle/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch' /usr/local/bundle/gems/thor-1.3.0/lib/thor/base.rb:584:in `start' /usr/local/bundle/gems/gcs-6.6.0/exe/gtcs:14:in `<top (required)>' /usr/local/bundle/bin/gtcs:25:in `load' /usr/local/bundle/bin/gtcs:25:in `<main>' ``` From the stacktrace, it appears this might have been introduced here: https://gitlab.com/gitlab-org/security-products/analyzers/container-scanning/-/merge_requests/2944 When we set the image back to use `6.5.1`, scan succeeds. ### Steps to reproduce See thread https://gitlab.com/gitlab-org/security-products/analyzers/container-scanning/-/merge_requests/2964?commit_id=62d6a504f18d49430bc75bfdf3f0c44c11b5bc15#note_1710640622 <!-- Describe how one can reproduce the issue - this is very important. Please use an ordered list. --> ### Example Project <!-- If possible, please create an example project here on GitLab.com that exhibits the problematic behavior, and link to it here in the bug report. If you are using an older version of GitLab, this will also determine whether the bug is fixed in a more recent version. --> ### What is the current *bug* behavior? Scan fails with an error. ### What is the expected *correct* behavior? Scan succeeds. ### Relevant logs and/or screenshots ``` [ERROR] [2023-12-21 07:43:05 +0000] [container-scanning] > different prefix: "" and "/builds/SNIPPED/SNIPPED" [ERROR] [2023-12-21 07:43:05 +0000] [container-scanning] > /usr/local/lib/ruby/3.1.0/pathname.rb:528:in `relative_path_from' /usr/local/bundle/gems/gcs-6.6.0/ee/lib/gcs/remediations/remediation.rb:112:in `diff_to_patch' /usr/local/bundle/gems/gcs-6.6.0/ee/lib/gcs/remediations/remediation.rb:104:in `create_patch' /usr/local/bundle/gems/gcs-6.6.0/ee/lib/gcs/remediations/remediation.rb:79:in `to_hash' /usr/local/bundle/gems/gcs-6.6.0/ee/lib/gcs/remediations/collection.rb:19:in `map' /usr/local/bundle/gems/gcs-6.6.0/ee/lib/gcs/remediations/collection.rb:19:in `to_hash' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/converter.rb:40:in `convert' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/plugin/container_scan.rb:10:in `convert' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/scan.rb:26:in `scan_image' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/cli.rb:16:in `block in scan' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/cli.rb:15:in `map' /usr/local/bundle/gems/gcs-6.6.0/lib/gcs/cli.rb:15:in `scan' /usr/local/bundle/gems/thor-1.3.0/lib/thor/command.rb:28:in `run' /usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command' /usr/local/bundle/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch' /usr/local/bundle/gems/thor-1.3.0/lib/thor/base.rb:584:in `start' /usr/local/bundle/gems/gcs-6.6.0/exe/gtcs:14:in `<top (required)>' /usr/local/bundle/bin/gtcs:25:in `load' /usr/local/bundle/bin/gtcs:25:in `<main>' ``` ### Output of checks <!-- If you are reporting a bug on GitLab.com, uncomment below --> <!-- This bug happens on GitLab.com --> <!-- /label ~"reproduced on GitLab.com" --> #### Results of GitLab environment info <!-- Input any relevant GitLab environment information if needed. --> <details> <summary>Expand for output related to GitLab environment info</summary> <pre> (For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`) </pre> </details> #### Results of GitLab application Check <!-- Input any relevant GitLab application check information if needed. --> <details> <summary>Expand for output related to the GitLab application check</summary> <pre> (For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:check SANITIZE=true`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true`) (we will only investigate if the tests are passing) </pre> </details> ### Possible fixes <!-- If you can, link to the line of code that might be responsible for the problem. -->
issue