Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/api/src/dfe/__tests__/org-connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,18 @@ describe('ensureOrgConnection', () => {
}),
);
const hunts = mockCreateSource.mock.calls.find(c => c[1].name === 'hunts');
expect(hunts?.[1].defaultTableSelectExpression).toBe(
'_timestamp,severity,hunt_name,rule_name,source_table,matched_uuid,rule_id,_json',
const select = hunts?.[1].defaultTableSelectExpression as string;
expect(
select.startsWith(
'_timestamp,severity,hunt_name,rule_name,source_table,',
),
).toBe(true);
expect(select.endsWith(',rule_id,_json')).toBe(true);
expect(select).not.toContain('_org_id');
// The cap's summary row renders as its counts, a match as its UUID.
expect(select).toContain(
"if(matched_uuid = toUUID('00000000-0000-0000-0000-000000000000'), concat('capped: ', toString(_json.written), ' of ', toString(_json.matched), ' kept'), toString(matched_uuid)) AS match",
);
expect(hunts?.[1].defaultTableSelectExpression).not.toContain('_org_id');
});

test('both DFE sources sit in the engine data database', async () => {
Expand Down
10 changes: 9 additions & 1 deletion packages/api/src/dfe/controllers/org-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,18 @@ function huntsSource(connectionId: string, m: OrgConnection) {
// Detection payload only -- drop the _org_id/_source header plumbing, keep
// the analyst-facing match columns plus the structured `_json`.
defaultTableSelectExpression:
'_timestamp,severity,hunt_name,rule_name,source_table,matched_uuid,rule_id,_json',
'_timestamp,severity,hunt_name,rule_name,source_table,' +
`${HUNT_MATCH_COLUMN},rule_id,_json`,
};
}

// A rule that fills its per-run cap leaves one summary row: nil matched_uuid, counts in _json.
const NIL_UUID = '00000000-0000-0000-0000-000000000000';
export const HUNT_MATCH_COLUMN =
`if(matched_uuid = toUUID('${NIL_UUID}'), ` +
"concat('capped: ', toString(_json.written), ' of ', toString(_json.matched), ' kept'), " +
'toString(matched_uuid)) AS match';

// PLATFORM-ONLY otel sources. The three below (log/trace/metric) are seeded ONLY
// on the platform/admin team - operator telemetry the standard OTel collector
// schema writes into the data database. Expressions match the columns upstream infers
Expand Down
Loading