mirror of
https://github.com/beenuar/AiSOC.git
synced 2026-12-03 10:57:40 +08:00
Waves 8 and 9 of v9.0. The public scoreboard sat frozen at 2026-07-13 / v7.5.0 for ten weeks across three releases while the page above it advertised weekly rows, and every check in the repository passed throughout. Three reasons, all of them the same mistake in different places. check_scoreboard's "freshness" meant the accuracy value was current. Nothing ever read a row's date. It also took the first substrate row in file order rather than the newest by date, so a row appended in the wrong place would silently have become the one every check measured. --refresh rewrote only mitre_accuracy, leaving date, commit_sha and agent_version untouched — so a refreshed row described today's code and claimed to have been measured in July, which is a worse state than a stale number because it looks current. And there was no writer at all. wet-eval rewrites benchmark.md and a snapshot and never touches scoreboard.json; live-agent-eval runs a real Ollama-hosted agent and had permissions: contents: read, so it could not have published its result if it tried. The docs promise an auto-PR appending a row and nothing implemented it. The ceiling is 45 days rather than 7 because the weekly job needs a funded provider key it does not have, and a gate that reds main permanently for a reason no contributor can fix is one people route around. Separately: both published Go SDKs declared github.com/beenuar/aisoc/<name> — wrong case against a case-sensitive VCS path, and missing the packages/ prefix — so go get resolved neither and neither was installable by anyone outside this repository. Every in-repo consumer used a replace directive, which is the shape that hides this: the tree builds perfectly and the published artifact does not exist. Co-authored-by: Beenu Arora <beenu@MacBook-Pro-3.local>
135 lines
3.5 KiB
Go
135 lines
3.5 KiB
Go
// Package main is the GitHub Audit Log connector reference implementation in Go.
|
|
//
|
|
// This file mirrors the Python plugin.py and demonstrates cross-language SDK
|
|
// parity. The AiSOC runtime currently invokes plugin.py at execution time;
|
|
// this Go reference is intended for operators who prefer to ship native
|
|
// binary plugins.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
"net/http"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc"
|
|
)
|
|
|
|
// GitHubAuditConnector implements aisoc.Connector against the GitHub Audit Log API.
|
|
type GitHubAuditConnector struct {
|
|
aisoc.BasePlugin
|
|
|
|
httpClient *http.Client
|
|
}
|
|
|
|
func (g *GitHubAuditConnector) Manifest() aisoc.PluginManifest {
|
|
return aisoc.PluginManifest{
|
|
ID: "github-audit",
|
|
Name: "GitHub Audit Log Connector",
|
|
Version: "1.0.0",
|
|
PluginType: aisoc.PluginTypeConnector,
|
|
Description: "Pulls GitHub org audit log events and secret-scanning alerts.",
|
|
Author: "AiSOC Core Team",
|
|
Tags: []string{"vcs", "github", "audit", "supply-chain"},
|
|
}
|
|
}
|
|
|
|
func (g *GitHubAuditConnector) OnLoad(ctx context.Context, pctx aisoc.PluginContext) error {
|
|
g.httpClient = &http.Client{Timeout: 30 * time.Second}
|
|
return nil
|
|
}
|
|
|
|
func (g *GitHubAuditConnector) TestConnection(ctx context.Context, pctx aisoc.PluginContext) (bool, error) {
|
|
if err := g.checkConfig(pctx); err != nil {
|
|
return false, err
|
|
}
|
|
req, err := g.newRequest(ctx, pctx, "GET", fmt.Sprintf("/orgs/%s", pctx.Config["org"]))
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
resp, err := g.httpClient.Do(req)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
defer resp.Body.Close()
|
|
if resp.StatusCode >= 400 {
|
|
return false, errors.New("github auth: " + resp.Status)
|
|
}
|
|
return true, nil
|
|
}
|
|
|
|
func (g *GitHubAuditConnector) FetchEvents(
|
|
ctx context.Context,
|
|
pctx aisoc.PluginContext,
|
|
since string,
|
|
) (<-chan map[string]any, error) {
|
|
out := make(chan map[string]any)
|
|
go func() {
|
|
defer close(out)
|
|
if err := g.checkConfig(pctx); err != nil {
|
|
out <- map[string]any{"error": err.Error()}
|
|
return
|
|
}
|
|
path := fmt.Sprintf("/orgs/%s/audit-log?per_page=100", pctx.Config["org"])
|
|
if since != "" {
|
|
path += "&after=" + since
|
|
}
|
|
req, err := g.newRequest(ctx, pctx, "GET", path)
|
|
if err != nil {
|
|
out <- map[string]any{"error": err.Error()}
|
|
return
|
|
}
|
|
resp, err := g.httpClient.Do(req)
|
|
if err != nil {
|
|
out <- map[string]any{"error": err.Error()}
|
|
return
|
|
}
|
|
defer resp.Body.Close()
|
|
var events []map[string]any
|
|
_ = json.NewDecoder(resp.Body).Decode(&events)
|
|
for _, e := range events {
|
|
out <- e
|
|
}
|
|
}()
|
|
return out, nil
|
|
}
|
|
|
|
func (g *GitHubAuditConnector) checkConfig(pctx aisoc.PluginContext) error {
|
|
for _, k := range []string{"org", "token"} {
|
|
if pctx.Config[k] == nil {
|
|
return fmt.Errorf("missing config key: %s", k)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (g *GitHubAuditConnector) newRequest(
|
|
ctx context.Context,
|
|
pctx aisoc.PluginContext,
|
|
method, path string,
|
|
) (*http.Request, error) {
|
|
base := "https://api.github.com"
|
|
if v, ok := pctx.Config["base_url"].(string); ok && v != "" {
|
|
base = strings.TrimRight(v, "/")
|
|
}
|
|
req, err := http.NewRequestWithContext(ctx, method, base+path, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req.Header.Set("Authorization", "Bearer "+pctx.Config["token"].(string))
|
|
req.Header.Set("Accept", "application/vnd.github+json")
|
|
req.Header.Set("X-GitHub-Api-Version", "2022-11-28")
|
|
return req, nil
|
|
}
|
|
|
|
func main() {
|
|
registry := aisoc.NewRegistry()
|
|
if err := registry.Register(&GitHubAuditConnector{}); err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println("github-audit reference plugin loaded")
|
|
}
|