Brainstorming "API" for tables used in containers
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 23.6k
- Forks
- 2.6k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 14
Description
Right now the current "API" for using a table in a container (see #6209) is to apply pid_with_namespace to the predicate.
I find the column name is slightly confusing to folks not using osquery for containers. I want to brainstorm some alternatives. Please keep in mind that I have not tested the applicability of the following, it is very possible that some ideas do not work in practice.
-
Introduce a function that resolves pid to namespace and only include
mount_namespace_idas an added column. I am imagining aSELECT * from os_version WHERE mount_namespace_id = pidToNamespace(12345);. -
Introduce a
VIEWfor each of these tables such that you have aSELECT *, pid_with_namespace, mount_namespace_id from os_version, call thiscontainerized_os_versionand make the two new columnsHIDDEN. This means normal calls toos_versionremain the same. -
Make use of the "column is used" functionality within virtual table implementations to populate
contextwith information. Then you can haveSELECT *, pidToNamespace(12345) from os_version, and the columns can becomeHIDDEN(see 2). -
Implement some SQL meta-programming to create an experience like
SELECT * FROM @containerized(os_version, pid=12345);orSELECT * FROM @containerized(os_version, namespace=12345);. We then intercept raw-queries and parse out the@containerized<$>to rewrite the query (yikes). Essentially create a temporaryVIEWfor this table and select from that. -
Set
pid_from_namespacetoHIDDENand keepmount_namespace_idas notHIDDEN. I do not thinkpid_from_namespaceprovides a lot of value as a returned column. The namespace ID should be enough to differentiate between containers. I would hope that the container-related tables return this namespace ID somehow?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading issue #6209 and reviewing the current pid_with_namespace approach described here. Compare the five proposed API designs against the existing container-table behavior and determine which direction is viable. The issue identifies no implementation files or tests; done would require an agreed design before implementation can be scoped.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, sql
- Domain
- api, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100