Skip to content

Develop#37

Merged
0xmanhnv merged 8 commits into
mainfrom
develop
Apr 8, 2026
Merged

Develop#37
0xmanhnv merged 8 commits into
mainfrom
develop

Conversation

@0xmanhnv
Copy link
Copy Markdown
Collaborator

@0xmanhnv 0xmanhnv commented Apr 8, 2026

No description provided.

0xmanhnv added 8 commits April 7, 2026 11:13
Problem: Asset owner info from external sources (GitHub org, CODEOWNERS
email, cloud tags, CSV imports) was lost because the system only supported
owner_id (FK to users table). If the owner hasn't registered, data is gone.

Solution: Add owner_ref VARCHAR(500) — stores raw owner text from any source.

Changes:
- Migration 101: add owner_ref column + index
- Entity: ownerRef field + getter/setter
- Repository: SELECT, INSERT, UPDATE, scan all include owner_ref
- API: owner_ref in CreateAssetRequest, AssetResponse
- Service: OwnerRef in CreateAssetInput
- Ingest: extractOwnerRef() reads from 5 CTIS sources:
  1. compliance.regulatory_owner (highest priority)
  2. technical.repository.owner (GitHub/GitLab org)
  3. properties.owner
  4. properties.contact
  5. properties.responsible

Display logic:
  owner_id set → show resolved user (name, email)
  owner_ref set → show raw text ('john@company.com (unresolved)')
  both null → show 'No owner'

Verified on live API: owner_ref stored and returned correctly.
Null byte fix:
- Strip \x00 from webhook name in constructor (same as asset entity)
- PostgreSQL rejects null bytes in UTF-8 strings → was causing 500

Auto-match owner_ref:
- Add UserMatcher interface to AssetService
- When owner_ref contains '@', auto-lookup user by email in tenant
- If found, set owner_id automatically
- Log successful matches for audit trail
- SetUserMatcher() for dependency injection (wired in services.go)
GO-2026-4947: x509 chain building (crypto/x509)
GO-2026-4946: x509 policy validation (crypto/x509)
GO-2026-4870: TLS 1.3 KeyUpdate DoS (crypto/tls)
GO-2026-4869: tar unbounded allocation (archive/tar)
GO-2026-4865: html/template XSS (html/template)

All fixed in go1.25.9+. Updating to go1.26 to match Dockerfile and CI.
- Add bootstrap-tenant CLI for creating first tenant + owner user
- Add to Dockerfile build stage and production image
- Fix IDOR in asset owner UpdateOwner/RemoveOwner (verify ownerID belongs to asset)
- Strengthen invitation token validation (len 40-100 instead of 10)
- Convert N+1 loop INSERTs to multi-row batch INSERT:
  - asset_group_repository.AddAssets
  - permission_set_repository.BatchAddItems/ReplaceItems
  - tenant_repository role assignment on invitation accept
- Make bootstrap-tenant role assignment fatal with role existence check
Workflows were using 1.25.8 but go.mod requires >= 1.26, causing
"go.mod requires go >= 1.26 (running go 1.25.8)" errors in CI.
@0xmanhnv 0xmanhnv merged commit ebe7caf into main Apr 8, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant