mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-03 20:21:51 +08:00
fix: display task intelligence content directly
This commit is contained in:
1 parent
d70dd15e11
commit
bd787f8883
6 files changed
+69
-90
No files matched your search
+2
-5
@@ -37,7 +37,6 @@ type Intelligence struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Inherited bool `json:"inherited"`
|
||||
Redacted bool `json:"redacted"`
|
||||
}
|
||||
type IntelligenceFilter struct {
|
||||
TaskID int64
|
||||
@@ -238,15 +237,14 @@ func (d *DB) ListIntelligence(ctx context.Context, f IntelligenceFilter) (*Intel
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Search metadata only: secrets are never searched or echoed through list endpoints.
|
||||
// Search titles and reporters; return the recorded content directly in each row.
|
||||
where := scope + ` AND ($3='' OR kind=$3) AND ($4='' OR i.status=$4) AND ($5='' OR i.title ILIKE '%'||$5||'%' OR i.worker ILIKE '%'||$5||'%')`
|
||||
args = append(args, f.Kind, f.Status, f.Query)
|
||||
if err = d.QueryRowContext(ctx, `SELECT count(*)`+where, args...).Scan(&page.Total); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args = append(args, f.Limit, f.Offset)
|
||||
// Do not load credential/data bodies into list responses at all.
|
||||
cols := `i.id,i.task_id,i.node_id,i.kind,i.title,CASE WHEN kind='lead' THEN content ELSE '' END,CASE WHEN kind='lead' THEN evidence ELSE '' END,confidence,i.status,asset_ids,i.worker,i.created_at,i.updated_at`
|
||||
cols := `i.id,i.task_id,i.node_id,i.kind,i.title,i.content,i.evidence,i.confidence,i.status,i.asset_ids,i.worker,i.created_at,i.updated_at`
|
||||
rows, err = d.QueryContext(ctx, `SELECT `+cols+where+` ORDER BY i.id DESC LIMIT $6 OFFSET $7`, args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -258,7 +256,6 @@ func (d *DB) ListIntelligence(ctx context.Context, f IntelligenceFilter) (*Intel
|
||||
return nil, e
|
||||
}
|
||||
item.Inherited = f.TaskID > 0 && item.TaskID != f.TaskID
|
||||
item.Redacted = item.Kind != "lead"
|
||||
page.Items = append(page.Items, item)
|
||||
}
|
||||
return page, rows.Err()
|
||||
|
||||
+25
-3
@@ -29,7 +29,7 @@ func TestIntelligenceValidation(t *testing.T) {
|
||||
t.Fatalf("normalization failed: %+v %v", got, err)
|
||||
}
|
||||
}
|
||||
func TestIntelligenceProvenanceDedupAndRedaction(t *testing.T) {
|
||||
func TestIntelligenceProvenanceDedupAndDirectContent(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -68,8 +68,8 @@ func TestIntelligenceProvenanceDedupAndRedaction(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
raw, _ := json.Marshal(page)
|
||||
if page.Total != 1 || !page.Items[0].Redacted || strings.Contains(string(raw), "local-fixture-secret") || strings.Contains(string(raw), "/tmp/fixture") {
|
||||
t.Fatal("list leaked secret or lost record")
|
||||
if page.Total != 1 || !strings.Contains(string(raw), "local-fixture-secret") || !strings.Contains(string(raw), "/tmp/fixture") {
|
||||
t.Fatal("list omitted recorded content or evidence")
|
||||
}
|
||||
if err = d.UpdateIntelligenceStatus(t.Context(), second.ID, item.ID, "verified"); !errors.Is(err, ErrIntelligenceNotFound) {
|
||||
t.Fatalf("cross-task mutation accepted: %v", err)
|
||||
@@ -119,3 +119,25 @@ func TestIntelligenceArchiveAssetRemapPreservesManualTriage(t *testing.T) {
|
||||
t.Fatal("remap lost dedup or manual triage")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntelligenceSensitiveDataListIncludesContent(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.Close()
|
||||
task, err := d.CreateTask("direct sensitive data display", "local fixture", nil, 0, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteTask(task.ID)
|
||||
in := IntelligenceInput{Kind: "sensitive_data", Title: "fixture dataset", Content: "[email protected]", Evidence: "/tmp/qa-users.json", Confidence: "observed"}
|
||||
_, err = d.RecordIntelligence(t.Context(), task.ID, 0, "qa", in)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
page, err := d.ListIntelligence(t.Context(), IntelligenceFilter{TaskID: task.ID, Kind: "sensitive_data"})
|
||||
if err != nil || page.Total != 1 || page.Items[0].Content != in.Content || page.Items[0].Evidence != in.Evidence {
|
||||
t.Fatalf("missing sensitive data content: %+v %v", page, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user