Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(push): use basename for artifacts when compressed in tar.gz #613

Merged

Conversation

alacuku
Copy link
Member

@alacuku alacuku commented Jul 24, 2024

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind feature

/kind flaky-test

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area library

/area cli

/area tests

/area examples

What this PR does / why we need it:

A registry push command like:

falcoctl registry push
   --type plugin --version 0.1.1 
   --requires plugin_api_version:3.1.0 
   --platform linux/amd64
   ghcr.io/alacuku/plugins/plugin/k8smeta:0.1.1 
   /home/aldo/Downloads/libk8smeta.so 

works fine, but when we try to install that artifact we get the following:

falcoctl artifact install ghcr.io/alacuku/plugins/plugin/k8smeta:0.1.1
2024-07-24 15:57:15 INFO  Resolving dependencies ... 
2024-07-24 15:57:16 INFO  Installing artifacts refs: [ghcr.io/alacuku/plugins/plugin/k8smeta:0.1.1]
2024-07-24 15:57:16 INFO  Preparing to pull artifact ref: ghcr.io/alacuku/plugins/plugin/k8smeta:0.1.1
2024-07-24 15:57:17 INFO  Pulling layer bb550464b415 
2024-07-24 15:57:17 INFO  Pulling layer 17c172171107                                                                                                                                                                                                                                                                                                                                                                              
2024-07-24 15:57:20 INFO  Pulling layer 6864efe49a85                                                                                                                                                                                                                                                                                                                                                                              
2024-07-24 15:57:20 INFO  Extracting and installing artifact type: plugin file: libk8smeta.tar.gz                                                                                                                                                                                                                                                                                                                                 
2024-07-24 15:57:20 ERROR cannot extract "/tmp/falcoctl4200489493/libk8smeta.tar.gz" to "/usr/share/falco/plugins": open                                                                                                                                                                                                                                                                                                          
                      │   /usr/share/falco/plugins/home/aldo/Downloads/libk8smeta.so: no such file or directory

The reason is that the tar header in the archive is the file path, in this case home/aldo/Downloads/libk8smeta.so. This PR ensures we use only the base name as a header in the tar archive, hence striping the components from the file path.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

When the artifact to be pushed has a folder in its path the full
name is used in the tar headers. This is an issue when we install the
artifact. This commits adds a flag that uses the basename when compressing
the artifact in the tar header.

Signed-off-by: Aldo Lacuku <[email protected]>
Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
/approve

@poiana
Copy link
Contributor

poiana commented Jul 24, 2024

LGTM label has been added.

Git tree hash: c1596e7fb07baabcd9ebd3074cf7649244e5f18d

@poiana
Copy link
Contributor

poiana commented Jul 24, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alacuku, FedeDP

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit d2a0104 into falcosecurity:main Jul 24, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants