Skip to content

Adding support for spec generation#129

Merged
directionless merged 15 commits intoosquery:masterfrom
directionless:seph/refactor-and-specs
Feb 10, 2026
Merged

Adding support for spec generation#129
directionless merged 15 commits intoosquery:masterfrom
directionless:seph/refactor-and-specs

Conversation

@directionless
Copy link
Member

@directionless directionless commented Feb 6, 2026

Why

I keep wanting to generate table specs from plugins. And so, I've revisited some work I started 6+ years ago.

Description

  1. Pulls column related stuff out of table.go into column.go
  2. Adds Function Arguments to a lot of constructors
  3. Adds arguments for things like "description", "notes", "examples"
  4. Updated the table example to dump the spec

Caveats:

  • Some of the table and column options may not be supported by osquery -- the underlying thrift protocol doesn't include them. But since some table implementations do use them, I included them for spec generation.
  • I tried to follow existing idioms. Some are kinda gnarly

Closes: #77
Closes: #78

directionless and others added 6 commits February 5, 2026 23:03
This is a WIP to generate table spec files.

It pulls out some stuff from `table.go` to `column.go`

To generate specs, we need to expand the options bitmask into the set of booleans. Instead of doing that via the bitmask (as in osquery#77), this explores storing these as booleans and generating the bitmask as needed.
@directionless directionless marked this pull request as ready for review February 6, 2026 05:47
@directionless directionless requested a review from Copilot February 6, 2026 13:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for generating osquery table specifications from plugin definitions. It refactors column-related code into a separate file and introduces the functional options pattern for configuring both tables and columns with metadata like descriptions, notes, examples, and platform information.

Changes:

  • Extracted column definitions and related code from table.go into a new column.go file
  • Added functional options pattern (TableOpt and ColumnOpt) to configure tables and columns with optional metadata
  • Implemented spec generation via a new Spec() method that outputs JSON-formatted table specifications
  • Added automatic platform detection based on runtime.GOOS with support for darwin, linux, and windows

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
plugin/table/table.go Added TableOpt functional options, platform detection logic, fixed typo in operator comment, added OperatorIn constant, and updated Routes() to use column Options() bitmask
plugin/table/column.go New file containing ColumnDefinition struct, column type constants, column helper functions, ColumnOpt functional options, and Options() bitmask method
plugin/table/column_test.go New file with basic test for Options() bitmask calculation
plugin/table/spec.go New file implementing Spec() method to generate JSON table specifications
plugin/table/spec_test.go New file with basic test for spec generation and custom JSON equality helper
examples/table/main.go Updated to demonstrate spec generation with --spec flag and usage of new functional options

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

directionless and others added 9 commits February 6, 2026 08:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@directionless directionless merged commit f77b3a1 into osquery:master Feb 10, 2026
3 checks passed
@directionless directionless deleted the seph/refactor-and-specs branch February 10, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants