-
Notifications
You must be signed in to change notification settings - Fork 29
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
Path elements in JSON output are not consistent between runs #48
Comments
I've noticed the same behavior when passing multiple packages to As an example, when running in the root directory of https://github.com/gravitational/teleport with Code I used to sort output: https://go.dev/play/p/kF3ARegvxKj (it expects to args: path to capslock output json file and a path to write the sorted output to). After running $ sha256sum sorted*
4a81e59c288df75face6790e683674b34dcb554d724fa15a80281fa8f1b33eaa sorted1.json
4cddf2ab60836109285e15107260ff813d48846faf3dc77f0c8af9aed3da34e6 sorted2.json
$ ls -la sorted*
-rw-r--r-- 1 capnspacehook capnspacehook 2752438 Oct 9 18:43 sorted1.json
-rw-r--r-- 1 capnspacehook capnspacehook 2758625 Oct 9 18:43 sorted2.json |
Thanks for the detailed reports! It looks like we have two underlying problems -- the lack of determinism in the choice of example call paths causing spurious diffs in the output, and incorrect mapping of call sites to source code locations when there is more than one input package specified. We're looking into this. |
An issue related to this is that when there are replace directives in the go.mod, the replaced package name is used, rather than the replacing package. This can be worked around after the fact, but can be confusing. |
I'm using capslock (probably in a way that is not intended) to identify module wide imports that are org-foreign. This is a cheap hack implemented here with obvious issues of false positives.
One of the extensions that I was interested in making was to use the path output to identify specific syscalls that are made when a CAPABILITY_SYSTEM_CALLS is fount. This requires examining the call path array in the capslock JSON output so that the AST of the package can be examined for the actual args of the sycall call. While looking into this, I found that the order of the input packages to capslock impacts on the output of the JSON and the final sites identified in the path are not stable between runs (the summary output and caps counts are stable).
To demonstrate this here are example runs of capslock with a post processor available here https://play.golang.com/p/JoC-mB_NZYA (built as an executable
syscalls
). The tests were run in packetbeat/protos directory of http://github.com/elastic/beats.Different packages order (note missing
unix.CmsgSpace
callsite is consistent between runs):Single package, multiple runs:
The text was updated successfully, but these errors were encountered: