{"id":25376670,"url":"https://github.com/scrymastic/goosquery","last_synced_at":"2025-04-09T10:31:42.298Z","repository":{"id":271649968,"uuid":"913174970","full_name":"scrymastic/goosquery","owner":"scrymastic","description":"goosquery","archived":false,"fork":false,"pushed_at":"2025-03-25T11:46:01.000Z","size":498,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T12:36:33.946Z","etag":null,"topics":["golang","networking","osquery","system"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scrymastic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-07T07:15:26.000Z","updated_at":"2025-03-25T11:46:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"0eae0f67-1b6d-4227-a4b5-592dd659bfc0","html_url":"https://github.com/scrymastic/goosquery","commit_stats":null,"previous_names":["scrymastic/go-osquery","scrymastic/goosquery"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrymastic%2Fgoosquery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrymastic%2Fgoosquery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrymastic%2Fgoosquery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrymastic%2Fgoosquery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scrymastic","download_url":"https://codeload.github.com/scrymastic/goosquery/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248020587,"owners_count":21034458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","networking","osquery","system"],"created_at":"2025-02-15T04:37:23.139Z","updated_at":"2025-04-09T10:31:42.263Z","avatar_url":"https://github.com/scrymastic.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003cspan style=\"font-weight: bold\"\u003egoosquery \u003c/span\u003e\n![Go](https://img.shields.io/badge/made%20with-Go-00ADD8)\n![Platform](https://img.shields.io/badge/platform-windows-0078D6)\n![License](https://img.shields.io/badge/license-MIT-yellow)\n\u003c/div\u003e\n\nGoosquery is a Go-based system information collection tool inspired by OSQuery. It provides a unified interface to collect various system information from Windows systems using SQL-like queries.\n\nSimple build process, straightforward table implementation, and seamless integration with other Go applications.\n\n## Table of Contents\n\n- [Notice](#notice)\n- [Advantages Over Original OSQuery](#advantages-over-original-osquery)\n- [Features](#features)\n- [Usage](#usage)\n  - [Interactive Mode](#interactive-mode)\n  - [Command Line Mode](#command-line-mode)\n  - [Output Formats](#output-formats)\n- [Examples](#examples)\n- [SQL Query Capabilities](#sql-query-capabilities)\n- [Available Tables](#available-tables)\n- [Development](#development)\n- [Implementation Status](#implementation-status)\n- [Adding New Tables](#adding-new-tables)\n\n## Notice\n\n\u003e [!IMPORTANT]  \n\u003e This project is under development.\n\n## Features\n\n- ✅ SQL-like query interface for accessing system information\n- ✅ Interactive mode with command history and autocompletion\n- ✅ Multiple output formats (table and JSON)\n- ✅ Modular design for easy extension with new tables\n- ✅ Efficient data collection with column-based filtering\n- ✅ Comprehensive table collection for Windows systems\n- ✅ Support for WHERE clauses to filter results\n\n## Usage\n\n### Interactive Mode\n\n```bash\n# Start in interactive mode with default table output\ngoosquery -i\n\n# Start in interactive mode with JSON output\ngoosquery -i -json\n```\n\nIn interactive mode, you can use the following commands:\n\n```\n.quit        - Exit the program\n.json        - Switch to JSON output mode\n.table       - Switch to table output mode  \n.mode        - Show current output mode\n.help        - Show help message\n```\n\n### Command Line Mode\n\n```bash\n# Execute a query directly from the command line\ngoosquery -q \"SELECT * FROM processes\"\n\n# Execute a query and output as JSON\ngoosquery -q \"SELECT name, pid FROM processes\" -json\n```\n\n### Output Formats\n\nGoOsquery supports two output formats:\n\n1. **Table Format (Default)**: Displays results in a formatted ASCII table\n   ```plaintext\n   ┌─────────┬─────┐\n   │ name    │ pid │\n   ├─────────┼─────┤\n   │ cmd.exe │ 123 │\n   └─────────┴─────┘\n   ```\n\n2. **JSON Format**: Outputs results as JSON data\n   ```json\n   [\n     {\n       \"name\": \"cmd\",\n       \"pid\": 123\n     }\n   ]\n   ```\n\n## Examples\n\nQuery processes:\n```sql\nSELECT name, pid, parent FROM processes WHERE name LIKE '%svc%';\n```\n\nQuery network interfaces:\n```sql\nSELECT interface, address, mask FROM interface_addresses;\n```\n\nCheck HTTP response from a website:\n```sql\nSELECT url, response_code, round_trip_time FROM curl WHERE url = 'https://example.com';\n```\n\n## SQL Query Capabilities\n\nGoOSQuery supports a wide range of SQL features for powerful data processing:\n\n### SQL Functions\n\n- **Aggregation Functions**:\n  - `COUNT(column)` - Count non-null values in a column\n  - `COUNT(DISTINCT column)` - Count unique values in a column\n  - `SUM(column)` - Sum of values in a column\n  - `AVG(column)` - Average of values in a column\n  - `MIN(column)` - Minimum value in a column\n  - `MAX(column)` - Maximum value in a column\n\n### Clauses and Operators\n\n- **SELECT** - Specify columns to retrieve\n- **FROM** - Specify the table to query\n- **WHERE** - Filter results based on conditions\n  - Comparison operators: `=`, `\u003c\u003e`, `\u003e`, `\u003e=`, `\u003c`, `\u003c=`\n  - Logical operators: `AND`, `OR`, `NOT`\n  - Pattern matching: `LIKE` with wildcards (`%`)\n  - Value checks: `IS NULL`, `IS NOT NULL`\n- **GROUP BY** - Group results by one or more columns\n- **ORDER BY** - Sort results by one or more columns\n  - Specify sort direction: `ASC` or `DESC`\n- **LIMIT** - Limit the number of returned rows\n\n### Examples\n\nCount processes by name:\n```sql\nSELECT name, COUNT(pid) AS count FROM processes GROUP BY name ORDER BY count DESC LIMIT 5;\n```\n\nGet average memory usage by process type:\n```sql\nSELECT name, AVG(memory) AS avg_memory FROM processes GROUP BY name;\n```\n\nFind listening ports with the highest average port number by process:\n```sql\nSELECT process_name, COUNT(port) as port_count, AVG(port) as avg_port \nFROM listening_ports \nGROUP BY process_name \nORDER BY avg_port DESC;\n```\n\n## Development\n\n### Implementation Status\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eStatus Legend\u003c/strong\u003e\u003c/summary\u003e\n\n| Status | Icon | Description |\n|--------|------|-------------|\n| Not Started | ⏳ | Work has not begun on this table yet. |\n| In Progress | 🛠️ | Actively being developed. |\n| Completed | ✅ | Fully implemented and tested. |\n| Testing | 🧪 | Development is done, but under testing for bugs or issues. |\n| Blocked | ⛔ | Development is paused due to dependencies, blockers, or technical issues. |\n| Planned | 🗓️ | Table is planned for future implementation but hasn't started yet. |\n| Deprecated | 🗑️ | This table is no longer relevant or supported in this implementation. |\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eTables Implementation Status\u003c/strong\u003e\u003c/summary\u003e\n\n| Table Name                       | Status  |\n|----------------------------------|---------|\n| appcompat_shims                  | 🧪      |\n| arp_cache                        | 🧪      |\n| authenticode                     | ✅      |\n| autoexec                         | ⏳      |\n| azure_instance_metadata          | ⏳      |\n| azure_instance_tags              | ⏳      |\n| background_activities_moderator  | 🧪      |\n| battery                          | ⛔      |\n| bitlocker_info                   | ✅      |\n| carbon_black_info                | ⏳      |\n| carves                           | ⏳      |\n| certificates                     | 🛠️      |\n| chassis_info                     | ✅      |\n| chocolatey_packages              | ✅      |\n| chrome_extension_content_scripts | ⏳      |\n| chrome_extensions                | ⏳      |\n| connectivity                     | ✅      |\n| cpu_info                         | ✅      |\n| cpuid                            | ⏳      |\n| curl                             | ✅      |\n| curl_certificate                 | ⏳      |\n| default_environment              | ✅      |\n| deviceguard_status               | ✅      |\n| disk_info                        | ✅      |\n| dns_cache                        | ✅      |\n| drivers                          | ✅      |\n| ec2_instance_metadata            | ⏳      |\n| ec2_instance_tags                | ⏳      |\n| etc_hosts                        | ✅      |\n| etc_protocols                    | ✅      |\n| etc_services                     | ✅      |\n| file                             | ✅      |\n| firefox_addons                   | ⏳      |\n| groups                           | ✅      |\n| hash                             | ✅      |\n| ie_extensions                    | ⏳      |\n| intel_me_info                    | ⏳      |\n| interface_addresses              | ✅      |\n| interface_details                | ✅      |\n| kernel_info                      | ✅      |\n| kva_speculative_info             | ✅      |\n| listening_ports                  | ✅      |\n| logged_in_users                  | ✅      |\n| logical_drives                   | ✅      |\n| logon_sessions                   | ✅      |\n| memory_devices                   | ✅      |\n| npm_packages                     | ⏳      |\n| ntdomains                        | ✅      |\n| ntfs_acl_permissions             | ⏳      |\n| ntfs_journal_events              | ⏳      |\n| office_mru                       | ⏳      |\n| os_version                       | ✅      |\n| osquery_events                   | 🗑️      |\n| osquery_extensions               | 🗑️      |\n| osquery_flags                    | 🗑️      |\n| osquery_info                     | 🗑️      |\n| osquery_packs                    | 🗑️      |\n| osquery_registry                 | 🗑️      |\n| osquery_schedule                 | 🗑️      |\n| patches                          | ✅      |\n| physical_disk_performance        | ⏳      |\n| pipes                            | 🧪      |\n| platform_info                    | ✅      |\n| powershell_events                | ⏳      |\n| prefetch                         | ⏳      |\n| process_etw_events               | ⏳      |\n| process_memory_map               | ✅      |\n| process_open_sockets             | ✅      |\n| processes                        | 🧪      |\n| programs                         | 🧪      |\n| python_packages                  | 🧪      |\n| registry                         | 🧪      |\n| routes                           | 🧪      |\n| scheduled_tasks                  | 🧪      |\n| secureboot                       | ⏳      |\n| security_profile_info            | 🛠️      |\n| services                         | ✅      |\n| shared_resources                 | ✅      |\n| shellbags                        | ⏳      |\n| shimcache                        | ⏳      |\n| ssh_configs                      | ⏳      |\n| startup_items                    | 🛠️      |\n| system_info                      | 🧪      |\n| time                             | ✅      |\n| tpm_info                         | ⏳      |\n| uptime                           | ✅      |\n| user_groups                      | 🧪      |\n| user_ssh_keys                    | ⏳      |\n| userassist                       | ⏳      |\n| users                            | ✅      |\n| video_info                       | ⏳      |\n| vscode_extensions                | ⏳      |\n| winbaseobj                       | 🧪      |\n| windows_crashes                  | ⏳      |\n| windows_eventlog                 | ⏳      |\n| windows_events                   | ⏳      |\n| windows_firewall_rules           | 🧪      |\n| windows_optional_features        | ✅      |\n| windows_search                   | ⛔      |\n| windows_security_center          | 🧪      |\n| windows_security_products        | 🛠️      |\n| windows_update_history           | 🛠️      |\n| wmi_bios_info                    | ⏳      |\n| wmi_cli_event_consumers          | ⏳      |\n| wmi_event_filters                | ⏳      |\n| wmi_filter_consumer_binding      | ⏳      |\n| wmi_script_event_consumers       | ⏳      |\n| yara                             | ⛔      |\n| yara_events                      | ⛔      |\n| ycloud_instance_metadata         | ⛔      |\n\u003c/details\u003e\n\n## Adding New Tables\n\nTo add a new table to Goosquery, follow these steps:\n\n1. Create a new package for your table under the appropriate category (e.g., `tables/system/newtable/`)\n\n2. Implement a data generator function with the following signature:\n   ```go\n   func GenNewTable(ctx *sqlctx.Context) (*result.Results, error)\n   ```\n   \n   This function should:\n   - Use the context.IsColumnUsed() method to check which columns are needed\n   - Only fetch the data needed for the columns requested\n   - Return data as a slice of maps where keys are column names\n\n3. Define column types in a map to ensure consistent type handling in `schema.go`:\n   ```go\n   var schema = result.Schema{\n       result.Column{Name: \"column1\", Type: \"TEXT\", Description: \"Description of column1\"},\n       result.Column{Name: \"column2\", Type: \"BIGINT\", Description: \"Description of column2\"},\n       result.Column{Name: \"column3\", Type: \"INTEGER\", Description: \"Description of column3\"},\n   }\n   ```\n\n4. Use the utility function to initialize columns with appropriate default values:\n   ```go\n   data := result.NewResult(ctx, schema)\n   ```\n\n5. Register the table in `sql/executor/executor.go` by adding a new case to the `GetExecutor` function:\n   ```go\n   case \"newtable\":\n       return \u0026impl.TableExecutor{\n           TableName:    \"newtable\",\n           Generator:    newtable.GenNewTable,\n       }, nil\n   ```\n\nThe `tableExecutor` pattern eliminates the need to write custom executor code for each table. It handles:\n- Extracting selected columns \n- Filtering with WHERE clauses\n- Projecting only requested columns\n\nThis design pattern reduces code duplication and ensures consistent behavior across all tables.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrymastic%2Fgoosquery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscrymastic%2Fgoosquery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrymastic%2Fgoosquery/lists"}