go: expose rulesets, passwd/group lookups and sock established - #386
Closed
nicholasberlin wants to merge 1 commit into
Closed
go: expose rulesets, passwd/group lookups and sock established#386nicholasberlin wants to merge 1 commit into
nicholasberlin wants to merge 1 commit into
Conversation
Close the gaps Go consumers are currently working around: - QueueAttr.RuleText installs a ruleset on the queue: parsed with quark_ruleset_parse() inside OpenQueue(), before any privileged operation, owned by the Queue and released on Close(). Processes matched by poison rules carry the tag in the new Process.PoisonTag. - PasswdLookup() and GroupLookup() mirror quark_passwd_lookup(3) and quark_group_lookup(3), so ECS-style consumers can resolve user and group names instead of skipping them. - QUARK_EV_SOCK_CONN_ESTABLISHED was the only event bit missing from the bindings; downstream hand-rolled the constant. TestRuleText checks parsing without root, TestQuark gains PasswdGroupLookup and RulePoison, the latter mirroring t_rule_poison. All Go tests pass as root, the full suite is unchanged.
This was referenced Aug 14, 2026
Merged
Contributor
Author
|
Superseded by single-concern PRs, one per concern:
The code in those PRs is identical to this one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the three gaps Go consumers are currently working around:
QueueAttr.RuleTextinstalls a ruleset on the queue. It's parsed withquark_ruleset_parse()insideOpenQueue()— before any privileged operation, so parse errors surface without root — via an fmemopen shim borrowed from quark-test'sruleset_from_string1(). The C ruleset is owned by theQueueand released onClose()(the queue only borrows the pointer). Processes matched by poison rules carry the tag in the newProcess.PoisonTag(set unconditionally, zero = no match, same semantics asquark_process.poison_tag). Until now the DSL — includingfile.exec_change— was unusable from Go.PasswdLookup()andGroupLookup()mirror quark_passwd_lookup(3) and quark_group_lookup(3). The otel quark receiver currently skipsuser.name/group.namein its ECS output with a comment noting the binding doesn't exist.QUARK_EV_SOCK_CONN_ESTABLISHED: the only event bit missing from the bindings (..._CLOSEDwas there); the otel receiver hand-rollsuint64(1) << 5today.Tests:
TestRuleTextcovers parse success/failure without root;TestQuarkgainsPasswdGroupLookup(uid/gid 0 resolve to root, unknown ids miss) andRulePoison, a Go port oft_rule_poison(poison children by ppid, pass only poisoned, drop the rest — every surviving event must carry the tag). RulePoison uses/bin/truerather than/bin/echoso it also runs in the initramfs VM.Verified: full Go suite passes as root on real hardware (
sudo ./quark-go-test -test.v, all 7 TestQuark subtests + TestRuleText); the new subtests also pass under krun with an initramfs augmented with glibc and /etc/passwd. go vet and gofmt clean.Next tier of exposure candidates (entity_id, change_mask, taints, id_change, packet payload) deliberately left out to keep this reviewable; container metadata is already in flight in #373/#380–383.