Skip to content

Commit c78811b

Browse files
ariosmontpapagian
authored andcommitted
docs: Add section on matchBinaries behavior with shebang scripts
Clarify that matchBinaries matches against the interpreter binary rather than the script path when executing scripts with shebangs, since the kernel executes the interpreter and passes the script as an argument. Signed-off-by: ariosmon <[email protected]>
1 parent 5a2da67 commit c78811b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/content/en/docs/concepts/tracing-policy/selectors.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,34 @@ while the whole `kprobe` call is the following:
328328
- "3"
329329
```
330330

331+
332+
### Scripts with shebangs
333+
334+
{{< caution >}}
335+
`matchBinaries` matches against the `interpreter`, not the script path.
336+
{{< /caution >}}
337+
338+
When executing a script with a shebang (i.e. `#!/usr/bin/python3`), Linux actually runs the
339+
interpreter and passes the script as an argument. Current implementation of `matchBinaries` filters based on the interpreter path (i.e. `/usr/bin/python3`) and not the script name (i.e. `/opt/scripts/my_script.py`).
340+
341+
This won't work:
342+
343+
```yaml
344+
- matchBinaries:
345+
- operator: "In"
346+
values:
347+
- "/opt/scripts/my_script.py"
348+
```
349+
350+
Match the interpreter instead:
351+
352+
```yaml
353+
- matchBinaries:
354+
- operator: "In"
355+
values:
356+
- "/usr/bin/python3"
357+
```
358+
331359
## Parent binaries filter
332360

333361
{{< warning >}}

0 commit comments

Comments
 (0)