UpdateAgentScanConfig writes the full screening config for an agent owned by userID, validating the effective posture first. Returns an error if the agent isn't found or isn't owned by the user.
(ctx context.Context, agentID, userID string, c ScanConfig)
| 93 | // userID, validating the effective posture first. Returns an error if the agent |
| 94 | // isn't found or isn't owned by the user. |
| 95 | func (s *Store) UpdateAgentScanConfig(ctx context.Context, agentID, userID string, c ScanConfig) error { |
| 96 | if err := ValidateScanConfig(c); err != nil { |
| 97 | return err |
| 98 | } |
| 99 | tag, err := s.pool.Exec(ctx, |
| 100 | `UPDATE agent_identities SET |
| 101 | inbound_policy_action = $3, |
| 102 | outbound_policy = $4, outbound_allowlist = $5, outbound_policy_action = $6, |
| 103 | inbound_scan = $7, inbound_scan_review_threshold = $8, inbound_scan_block_threshold = $9, |
| 104 | outbound_scan = $10, outbound_scan_review_threshold = $11, outbound_scan_block_threshold = $12 |
| 105 | WHERE id = $1 AND user_id = $2`, |
| 106 | agentID, userID, |
| 107 | c.InboundPolicyAction, |
| 108 | c.OutboundPolicy, c.OutboundAllowlist, c.OutboundPolicyAction, |
| 109 | c.InboundScan, c.InboundScanReviewThreshold, c.InboundScanBlockThreshold, |
| 110 | c.OutboundScan, c.OutboundScanReviewThreshold, c.OutboundScanBlockThreshold, |
| 111 | ) |
| 112 | if err != nil { |
| 113 | return err |
| 114 | } |
| 115 | if tag.RowsAffected() == 0 { |
| 116 | return fmt.Errorf("agent not found or not owned by user") |
| 117 | } |
| 118 | return nil |
| 119 | } |