Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package inspektor-gadget for 
openSUSE:Factory checked in at 2026-11-27 19:42:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/inspektor-gadget (Old)
 and      /work/SRC/openSUSE:Factory/.inspektor-gadget.new.1340718 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "inspektor-gadget"

Fri Nov 27 19:42:58 2026 rev:44 rq:1401035 version:0.58.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/inspektor-gadget/inspektor-gadget.changes        
2026-11-06 19:58:49.026292185 +0100
+++ 
/work/SRC/openSUSE:Factory/.inspektor-gadget.new.1340718/inspektor-gadget.changes
   2026-11-27 19:45:28.964039889 +0100
@@ -1,0 +2,7 @@
+Fri Nov 27 05:51:28 UTC 2026 - Johannes Kastl 
<[email protected]>
+
+- Update to version 0.58.1:
+  * Bugfixes
+    - [BACKPORT] Harden build subcommand in #6001
+
+-------------------------------------------------------------------

Old:
----
  inspektor-gadget-0.58.0.obscpio

New:
----
  inspektor-gadget-0.58.1.obscpio

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ inspektor-gadget.spec ++++++
--- /var/tmp/diff_new_pack.HVXkOm/_old  2026-11-27 19:45:30.931123399 +0100
+++ /var/tmp/diff_new_pack.HVXkOm/_new  2026-11-27 19:45:30.934123527 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           inspektor-gadget
-Version:        0.58.0
+Version:        0.58.1
 Release:        0
 Summary:        An eBPF tool and systems inspection framework
 License:        Apache-2.0

++++++ _service ++++++
--- /var/tmp/diff_new_pack.HVXkOm/_old  2026-11-27 19:45:30.982125564 +0100
+++ /var/tmp/diff_new_pack.HVXkOm/_new  2026-11-27 19:45:30.987125777 +0100
@@ -3,7 +3,7 @@
     <param 
name="url">https://github.com/inspektor-gadget/inspektor-gadget.git</param>
     <param name="scm">git</param>
     <param name="exclude">.git</param>
-    <param name="revision">refs/tags/v0.58.0</param>
+    <param name="revision">refs/tags/v0.58.1</param>
     <param name="versionformat">@PARENT_TAG@</param>
     <param name="versionrewrite-pattern">v(.*)</param>
     <param name="changesgenerate">enable</param>

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.HVXkOm/_old  2026-11-27 19:45:31.019127135 +0100
+++ /var/tmp/diff_new_pack.HVXkOm/_new  2026-11-27 19:45:31.024127348 +0100
@@ -3,6 +3,6 @@
                 <param 
name="url">https://github.com/inspektor-gadget/inspektor-gadget</param>
               <param 
name="changesrevision">7a314380ff61534ea70df9fb086505f958b2dff9</param></service><service
 name="tar_scm">
                 <param 
name="url">https://github.com/inspektor-gadget/inspektor-gadget.git</param>
-              <param 
name="changesrevision">461906a52de982c1b1ad80f9c2faaa9595c47550</param></service></servicedata>
+              <param 
name="changesrevision">08253ff8401eda2c4f9f07042706c0d2a9abfddc</param></service></servicedata>
 (No newline at EOF)
 

++++++ inspektor-gadget-0.58.0.obscpio -> inspektor-gadget-0.58.1.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/inspektor-gadget-0.58.0/cmd/common/image/build-step.go 
new/inspektor-gadget-0.58.1/cmd/common/image/build-step.go
--- old/inspektor-gadget-0.58.0/cmd/common/image/build-step.go  2026-11-04 
11:38:13.000000000 +0100
+++ new/inspektor-gadget-0.58.1/cmd/common/image/build-step.go  2026-11-26 
10:56:37.000000000 +0100
@@ -15,9 +15,12 @@
 package image
 
 import (
+       "encoding/json"
        "fmt"
        "path/filepath"
+       "regexp"
        "runtime"
+       "slices"
        "strings"
 
        "github.com/inspektor-gadget/inspektor-gadget/pkg/oci"
@@ -109,7 +112,7 @@
                        // -buildmode=c-shared to build the wasm as a reactor 
module, see:
                        // 
https://github.com/WebAssembly/WASI/blob/main/legacy/application-abi.md#current-unstable-abi
                        "-buildmode=c-shared",
-                       "-ldflags", "-w -s",
+                       "-ldflags", "-w -s", "--",
                        filepath.Base(goBuildStep.opts.wasmSourcePath),
                }
                env := []string{
@@ -135,10 +138,11 @@
                if cargoBuildStep.opts.forceColorsFlag {
                        cmd = append(cmd, "--color", "always")
                }
+               manifestPath := 
filepath.Join(filepath.Dir(cargoBuildStep.opts.wasmSourcePath), "..", 
"Cargo.toml")
                cmd = append(cmd,
                        "build",
                        "--target", "wasm32-wasip1", "--release",
-                       "--manifest-path", 
filepath.Join(filepath.Dir(cargoBuildStep.opts.wasmSourcePath), "..", 
"Cargo.toml"),
+                       "--manifest-path="+manifestPath,
                )
                env := []string{fmt.Sprintf("CARGO_TARGET_DIR=%s", 
cargoBuildStep.opts.outputDir)}
 
@@ -146,18 +150,23 @@
                        return fmt.Errorf("cargo build: %w", err)
                }
 
-               cargoTomlPath := 
filepath.Join(filepath.Dir(cargoBuildStep.opts.wasmSourcePath), "..", 
"Cargo.toml")
-               awkOut, _, err := runner.run([]string{
-                       "awk", "-F", `"`, `/^name *=/ { print $2; exit }`, 
cargoTomlPath,
+               metadataOut, _, err := runner.run([]string{
+                       "cargo", "metadata", "--format-version=1", "--no-deps",
+                       "--manifest-path=" + manifestPath,
                }, nil)
                if err != nil {
-                       return fmt.Errorf("reading package name from 
Cargo.toml: %w", err)
+                       return fmt.Errorf("cargo metadata: %w", err)
                }
-               packageName := strings.TrimSpace(awkOut)
 
-               src := filepath.Join(cargoBuildStep.opts.outputDir, 
"wasm32-wasip1", "release", packageName+".wasm")
+               targetName, err := cargoWasmTargetName(metadataOut)
+               if err != nil {
+                       return err
+               }
+
+               // cargo replaces "-" by "_" in the output file name.
+               src := filepath.Join(cargoBuildStep.opts.outputDir, 
"wasm32-wasip1", "release", strings.ReplaceAll(targetName, "-", "_")+".wasm")
                dst := filepath.Join(cargoBuildStep.opts.outputDir, 
"program.wasm")
-               if _, _, err := runner.run([]string{"cp", src, dst}, nil); err 
!= nil {
+               if _, _, err := runner.run([]string{"cp", "--", src, dst}, 
nil); err != nil {
                        return fmt.Errorf("copying wasm output: %w", err)
                }
 
@@ -167,6 +176,47 @@
        return cargoBuildStep
 }
 
+type cargoMetadata struct {
+       Packages []struct {
+               Targets []struct {
+                       Name string   `json:"name"`
+                       Kind []string `json:"kind"`
+               } `json:"targets"`
+       } `json:"packages"`
+}
+
+var cargoTargetNameRe = regexp.MustCompile(`^[A-Za-z0-9_-]+$`)
+
+// cargoWasmTargetName returns the name of the cdylib target from the output
+// of "cargo metadata --format-version=1 --no-deps".
+func cargoWasmTargetName(metadataOut string) (string, error) {
+       var metadata cargoMetadata
+       if err := json.Unmarshal([]byte(metadataOut), &metadata); err != nil {
+               return "", fmt.Errorf("parsing cargo metadata output (if using 
--local, try building in container): %w", err)
+       }
+
+       if len(metadata.Packages) != 1 {
+               return "", fmt.Errorf("expected exactly one cargo package, got 
%d (cargo workspaces are not supported)", len(metadata.Packages))
+       }
+
+       var names []string
+       for _, target := range metadata.Packages[0].Targets {
+               if slices.Contains(target.Kind, "cdylib") {
+                       names = append(names, target.Name)
+               }
+       }
+
+       if len(names) != 1 {
+               return "", fmt.Errorf("expected exactly one cdylib target, got 
%d", len(names))
+       }
+
+       if !cargoTargetNameRe.MatchString(names[0]) {
+               return "", fmt.Errorf("invalid cdylib target name: %q", 
names[0])
+       }
+
+       return names[0], nil
+}
+
 func newBtfgenStep(targetArch string, opts buildOptions) buildStep {
        btfgenStep := buildStep{
                opts:       opts,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inspektor-gadget-0.58.0/cmd/common/image/build.go 
new/inspektor-gadget-0.58.1/cmd/common/image/build.go
--- old/inspektor-gadget-0.58.0/cmd/common/image/build.go       2026-11-04 
11:38:13.000000000 +0100
+++ new/inspektor-gadget-0.58.1/cmd/common/image/build.go       2026-11-26 
10:56:37.000000000 +0100
@@ -146,6 +146,51 @@
        return nil
 }
 
+// checkBuildFilePath ensures path, relative to gadgetDir, does not point
+// outside of gadgetDir, including through symlinks. gadgetDir must already
+// have its symlinks resolved.
+func checkBuildFilePath(gadgetDir, path string) error {
+       if !filepath.IsLocal(path) {
+               return fmt.Errorf("%q must be a relative path inside the gadget 
directory", path)
+       }
+
+       // filepath.Join() lexically removes "..", which does not follow the
+       // filesystem resolution: "link/../x" would be checked as "x" while the
+       // kernel resolves ".." relative to the symlink target.
+       if slices.Contains(strings.Split(filepath.ToSlash(path), "/"), "..") {
+               return fmt.Errorf("%q must not contain \"..\"", path)
+       }
+
+       joined := filepath.Join(gadgetDir, path)
+
+       resolved, err := filepath.EvalSymlinks(joined)
+       if errors.Is(err, os.ErrNotExist) {
+               // The file may be created later (e.g. metadata with
+               // --update-metadata), so ensure it would be created inside 
gadgetDir.
+               if _, err := os.Lstat(joined); err == nil {
+                       return fmt.Errorf("%q is a dangling symlink", path)
+               }
+
+               resolved, err = filepath.EvalSymlinks(filepath.Dir(joined))
+               if errors.Is(err, os.ErrNotExist) {
+                       // Parent does not exist either, nothing can be created 
there.
+                       return nil
+               }
+               if err != nil {
+                       return fmt.Errorf("resolving parent of %q: %w", path, 
err)
+               }
+       } else if err != nil {
+               return fmt.Errorf("resolving %q: %w", path, err)
+       }
+
+       rel, err := filepath.Rel(gadgetDir, resolved)
+       if err != nil || !filepath.IsLocal(rel) {
+               return fmt.Errorf("%q points outside the gadget directory", 
path)
+       }
+
+       return nil
+}
+
 func buildPipeline(opts buildOptions) ([]buildStep, error) {
        if err := checkBuildOptions(opts); err != nil {
                return nil, fmt.Errorf("wrong build option detected: %w", err)
@@ -252,6 +297,31 @@
                }
        }
 
+       gadgetDir, err := os.Getwd()
+       if err != nil {
+               return fmt.Errorf("getting gadget directory: %w", err)
+       }
+       gadgetDir, err = filepath.EvalSymlinks(gadgetDir)
+       if err != nil {
+               return fmt.Errorf("resolving gadget directory: %w", err)
+       }
+
+       for _, f := range []struct {
+               name string
+               path string
+       }{
+               {"ebpfsource", conf.EBPFSource},
+               {"wasm", conf.Wasm},
+               {"metadata", conf.Metadata},
+       } {
+               if f.path == "" {
+                       continue
+               }
+               if err := checkBuildFilePath(gadgetDir, f.path); err != nil {
+                       return fmt.Errorf("build.yaml: %s: %w", f.name, err)
+               }
+       }
+
        if _, err := os.Stat(conf.EBPFSource); errors.Is(err, os.ErrNotExist) {
                if conf.EBPFSource != DEFAULT_EBPF_SOURCE {
                        return fmt.Errorf("source file %q not found", 
conf.EBPFSource)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/inspektor-gadget-0.58.0/docs/gadget-devel/building.md 
new/inspektor-gadget-0.58.1/docs/gadget-devel/building.md
--- old/inspektor-gadget-0.58.0/docs/gadget-devel/building.md   2026-11-04 
11:38:13.000000000 +0100
+++ new/inspektor-gadget-0.58.1/docs/gadget-devel/building.md   2026-11-26 
10:56:37.000000000 +0100
@@ -52,9 +52,10 @@
 
 - `ebpfsource`: eBPF source code file. It defaults to `program.bpf.c`.
 - `metadata`: File containing metadata about the gadget. It defaults to 
`gadget.yaml`.
-- `wasm`: Wasm module. It is unset by default. This field supports two kind of 
files:
+- `wasm`: Wasm module. It is unset by default. This field supports three kinds 
of files:
     - `*.wasm`: prebuilt Wasm module
     - `*.go`: automatically built
+    - `*.rs`: automatically built with cargo, using the `Cargo.toml` in the 
parent directory
 - `cflags`: The C flags used to compile the eBPF program. It is unset by 
default.
 
 By default, the build command looks for `build.yaml` in PATH. It can be 
changed with the `--file` flag:
@@ -89,6 +90,20 @@
 $ sudo CLANG=clang-15 LLVM_STRIP=llvm-strip-15 ig image build . -f 
mybuild.yaml --local
 ```
 
+## Building untrusted gadgets
+
+Only build gadgets from sources you trust.
+
+When the `wasm` field points to Rust source code (`*.rs`), the build runs
+`cargo`, which executes code provided by the gadget sources and their
+dependencies, such as build scripts (`build.rs`) and procedural macros. This
+also applies when building in the builder container.
+
+When `--local` is used, all the build tools run directly on the host, with
+the permissions of the user running `ig` (root when using `sudo`). Any code
+run by the build, or files embedded by it, can access the whole host. Use
+`--local` only with trusted sources.
+
 ## Reproducible builds
 
 The `build` command supports the

++++++ inspektor-gadget.obsinfo ++++++
--- /var/tmp/diff_new_pack.HVXkOm/_old  2026-11-27 19:45:33.458230684 +0100
+++ /var/tmp/diff_new_pack.HVXkOm/_new  2026-11-27 19:45:33.464230939 +0100
@@ -1,5 +1,5 @@
 name: inspektor-gadget
-version: 0.58.0
-mtime: 1793788693
-commit: 461906a52de982c1b1ad80f9c2faaa9595c47550
+version: 0.58.1
+mtime: 1795686997
+commit: 08253ff8401eda2c4f9f07042706c0d2a9abfddc
 

++++++ vendor.tar.gz ++++++
/work/SRC/openSUSE:Factory/inspektor-gadget/vendor.tar.gz 
/work/SRC/openSUSE:Factory/.inspektor-gadget.new.1340718/vendor.tar.gz differ: 
char 13, line 1

Reply via email to