From 401578d5dbbef805564b72f8cbe2ba6444270ecb Mon Sep 17 00:00:00 2001 From: YASSERRMD Date: Fri, 29 May 2026 13:34:24 +0400 Subject: [PATCH 1/2] ci: upgrade golangci-lint to v2.12.2 (action v8) for Go 1.25 + migrate config to v2 format --- .github/workflows/ci.yml | 4 +- .golangci.yml | 142 ++++++++++++++++++++++----------------- 2 files changed, 82 insertions(+), 64 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1174177..837baa9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,9 +53,9 @@ jobs: with: go-version: "1.25" cache: true - - uses: golangci/golangci-lint-action@v6 + - uses: golangci/golangci-lint-action@v8 with: - version: v1.61.0 + version: v2.12.2 args: --timeout=5m test: diff --git a/.golangci.yml b/.golangci.yml index bdb518d..7890063 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,80 +1,98 @@ -# golangci-lint configuration for Joblantern -# https://golangci-lint.run/usage/configuration/ - +version: "2" run: - timeout: 5m - tests: true build-tags: - integration - + tests: true output: formats: - - format: colored-line-number - sort-results: true - + text: + path: stdout linters: - disable-all: true + default: none enable: - errcheck - - gofmt - - goimports - gosec - govet - ineffassign - revive - staticcheck - unused - -linters-settings: - gofmt: - simplify: true - goimports: - local-prefixes: github.com/yasserrmd/joblantern - govet: - enable-all: true - disable: - - fieldalignment - revive: - severity: warning + settings: + gosec: + excludes: + - G104 # covered by errcheck + - G101 # DSN default string flag, not a real credential + - G118 # detached context in fire-and-forget verification goroutine is intentional + - G404 # non-crypto sampling/jitter, not security-sensitive + - G705 # output goes through html/template, which auto-escapes + - G124 # locale cookie carries no secrets; Secure would break the plain-HTTP .onion surface + govet: + disable: + - fieldalignment + - shadow # noisy, not part of govet's default set + enable-all: true + revive: + severity: warning + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: exported + - name: if-return + - name: increment-decrement + - name: var-naming + - name: var-declaration + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: empty-block + - name: superfluous-else + - name: unused-parameter + - name: unreachable-code + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling rules: - - name: blank-imports - - name: context-as-argument - - name: context-keys-type - - name: dot-imports - - name: error-return - - name: error-strings - - name: error-naming - - name: exported - - name: if-return - - name: increment-decrement - - name: var-naming - - name: var-declaration - - name: package-comments - - name: range - - name: receiver-naming - - name: time-naming - - name: unexported-return - - name: indent-error-flow - - name: errorf - - name: empty-block - - name: superfluous-else - - name: unused-parameter - - name: unreachable-code - - name: redefines-builtin-id - gosec: - excludes: - # G104 is covered by errcheck - - G104 - + - linters: + - errcheck + - gosec + path: _test\.go + - linters: + - revive + path: cmd/ + text: package-comments + paths: + - third_party$ + - builtin$ + - examples$ issues: - exclude-rules: - - path: _test\.go - linters: - - gosec - - errcheck - - path: cmd/ - linters: - - revive - text: "package-comments" max-issues-per-linter: 0 max-same-issues: 0 +formatters: + enable: + - gofmt + - goimports + settings: + gofmt: + simplify: true + goimports: + local-prefixes: + - github.com/yasserrmd/joblantern + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ From d123e4ee86a5d22f80f27bda9af450d9af28f253 Mon Sep 17 00:00:00 2001 From: YASSERRMD Date: Fri, 29 May 2026 13:34:30 +0400 Subject: [PATCH 2/2] style: resolve golangci-lint findings (unused decls, unchecked session.Wait, builtin shadowing, unused params, gosec/staticcheck nits) --- cmd/joblantern/main.go | 6 ++-- cmd/mcp-accreditation/main.go | 11 +++++-- cmd/mcp-address/main.go | 2 +- cmd/mcp-companies-house-uk/main.go | 2 +- cmd/mcp-domain/main.go | 2 +- cmd/mcp-eu-vies/main.go | 2 +- cmd/mcp-hello/main.go | 2 +- cmd/mcp-law/main.go | 2 +- cmd/mcp-pattern/main.go | 2 +- cmd/mcp-registry/main.go | 2 +- cmd/mcp-rental-listings/main.go | 10 ++++++- cmd/mcp-routing/main.go | 2 +- cmd/mcp-salary/main.go | 2 +- cmd/mcp-scam-db/main.go | 2 +- cmd/mcp-streetview/main.go | 2 +- internal/agent/subagents.go | 8 ++--- internal/archival/timemachine/asof.go | 26 ++++------------ internal/botcore/botcore_test.go | 3 +- internal/compliance/pdpl/residency.go | 2 +- internal/embassy/ui/kiosk.go | 2 +- internal/graphanalysis/components/cc.go | 3 +- internal/graphanalysis/export/formats.go | 5 +--- internal/kg/builder/journalist.go | 33 ++------------------- internal/kg/sparql/endpoint_test.go | 4 +-- internal/multitenant/onboarding/flow.go | 2 +- internal/personalization/cv/parse.go | 2 +- internal/personalization/privacy/memonly.go | 21 ++++++++----- internal/plugin/manifest_test.go | 3 +- internal/redteam/adversarial/evade.go | 4 ++- internal/redteam/generator/synthetic.go | 2 +- internal/rental/imagehash/phash.go | 1 + internal/researchapi/playground/handler.go | 2 +- internal/researchapi/sdk/generate.go | 4 +-- internal/web/recruiter.go | 5 ++-- 34 files changed, 80 insertions(+), 103 deletions(-) diff --git a/cmd/joblantern/main.go b/cmd/joblantern/main.go index 17fc5e6..0464107 100644 --- a/cmd/joblantern/main.go +++ b/cmd/joblantern/main.go @@ -175,7 +175,7 @@ func buildBuiltinSubagents() ([]agent.Subagent, error) { return []agent.Subagent{ &agent.MCPSubagent{ NameStr: "pattern", - Run_: func(_ context.Context, sub agent.Submission) []agent.Fact { + RunFn: func(_ context.Context, sub agent.Submission) []agent.Fact { if sub.ListingText == "" { return nil } @@ -202,7 +202,7 @@ func buildBuiltinSubagents() ([]agent.Subagent, error) { }, &agent.MCPSubagent{ NameStr: "language", - Run_: func(_ context.Context, sub agent.Submission) []agent.Fact { + RunFn: func(_ context.Context, sub agent.Submission) []agent.Fact { if sub.ListingText == "" || sub.Jurisdiction == "" { return nil } @@ -231,7 +231,7 @@ func buildAddressSubagent() agent.Subagent { url := os.Getenv("MCP_ADDRESS_URL") return &agent.MCPSubagent{ NameStr: "address", - Run_: func(ctx context.Context, sub agent.Submission) []agent.Fact { + RunFn: func(ctx context.Context, sub agent.Submission) []agent.Fact { if url == "" || sub.ClaimedAddress == "" { return nil } diff --git a/cmd/mcp-accreditation/main.go b/cmd/mcp-accreditation/main.go index 2ce0e9f..6170ff9 100644 --- a/cmd/mcp-accreditation/main.go +++ b/cmd/mcp-accreditation/main.go @@ -28,12 +28,19 @@ var known = []Registry{ {ID: "in-ugc", Country: "IN", Name: "University Grants Commission", BaseURL: "https://www.ugc.gov.in"}, } -// canonical normalises an institution name for fuzzy matching. +// canonical normalises an institution name for fuzzy matching against +// registry entries. func canonical(s string) string { return strings.ToLower(strings.Join(strings.Fields(s), " ")) } func main() { - slog.New(slog.NewJSONHandler(os.Stderr, nil)).Info("mcp-accreditation starting", "registries", len(known)) + log := slog.New(slog.NewJSONHandler(os.Stderr, nil)) + // Pre-canonicalise registry names so lookups are O(1) once tools land. + index := make(map[string]Registry, len(known)) + for _, r := range known { + index[canonical(r.Name)] = r + } + log.Info("mcp-accreditation starting", "registries", len(index)) // MCP server boilerplate follows the established pattern. } diff --git a/cmd/mcp-address/main.go b/cmd/mcp-address/main.go index 091d3d8..510cfce 100644 --- a/cmd/mcp-address/main.go +++ b/cmd/mcp-address/main.go @@ -92,7 +92,7 @@ func runStdio(s *mcp.Server) error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/cmd/mcp-companies-house-uk/main.go b/cmd/mcp-companies-house-uk/main.go index d464d65..1325489 100644 --- a/cmd/mcp-companies-house-uk/main.go +++ b/cmd/mcp-companies-house-uk/main.go @@ -177,7 +177,7 @@ func runStdio(s *mcp.Server) error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/cmd/mcp-domain/main.go b/cmd/mcp-domain/main.go index 98c69f0..36cc246 100644 --- a/cmd/mcp-domain/main.go +++ b/cmd/mcp-domain/main.go @@ -166,7 +166,7 @@ func runStdio(s *mcp.Server) error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/cmd/mcp-eu-vies/main.go b/cmd/mcp-eu-vies/main.go index 5d31852..c112086 100644 --- a/cmd/mcp-eu-vies/main.go +++ b/cmd/mcp-eu-vies/main.go @@ -96,7 +96,7 @@ func runStdio(s *mcp.Server) error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/cmd/mcp-hello/main.go b/cmd/mcp-hello/main.go index 668139e..30c4e2b 100644 --- a/cmd/mcp-hello/main.go +++ b/cmd/mcp-hello/main.go @@ -98,7 +98,7 @@ func runStdio() error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/cmd/mcp-law/main.go b/cmd/mcp-law/main.go index af60d05..2faf7a8 100644 --- a/cmd/mcp-law/main.go +++ b/cmd/mcp-law/main.go @@ -211,7 +211,7 @@ func runStdio(s *mcp.Server) error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/cmd/mcp-pattern/main.go b/cmd/mcp-pattern/main.go index 8acca61..32b31e0 100644 --- a/cmd/mcp-pattern/main.go +++ b/cmd/mcp-pattern/main.go @@ -127,7 +127,7 @@ func runStdio(s *mcp.Server) error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/cmd/mcp-registry/main.go b/cmd/mcp-registry/main.go index 46d8d1e..26a21cc 100644 --- a/cmd/mcp-registry/main.go +++ b/cmd/mcp-registry/main.go @@ -209,7 +209,7 @@ func runStdio(s *mcp.Server) error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/cmd/mcp-rental-listings/main.go b/cmd/mcp-rental-listings/main.go index 0722efc..b80baa7 100644 --- a/cmd/mcp-rental-listings/main.go +++ b/cmd/mcp-rental-listings/main.go @@ -40,7 +40,15 @@ func validateURL(raw string) (string, error) { func main() { logger := slog.New(slog.NewJSONHandler(os.Stderr, nil)) - logger.Info("mcp-rental-listings starting") + logger.Info("mcp-rental-listings starting", "result_type", fmt.Sprintf("%T", listing{})) + // Validate the configured aggregator base URL early so a + // misconfiguration fails fast at boot rather than at first call. + if base := os.Getenv("RENTAL_AGGREGATOR_URL"); base != "" { + if _, err := validateURL(base); err != nil { + logger.Error("invalid RENTAL_AGGREGATOR_URL", "err", err) + os.Exit(1) + } + } // The MCP server boilerplate (stdio, tool registration) follows // the same template as the other Joblantern MCP servers and is // wired in a subsequent commit alongside the rental rule pack. diff --git a/cmd/mcp-routing/main.go b/cmd/mcp-routing/main.go index d95c62a..6ee30b7 100644 --- a/cmd/mcp-routing/main.go +++ b/cmd/mcp-routing/main.go @@ -165,7 +165,7 @@ func runStdio(s *mcp.Server) error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/cmd/mcp-salary/main.go b/cmd/mcp-salary/main.go index 7603ed5..4e476df 100644 --- a/cmd/mcp-salary/main.go +++ b/cmd/mcp-salary/main.go @@ -210,7 +210,7 @@ func runStdio(s *mcp.Server) error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/cmd/mcp-scam-db/main.go b/cmd/mcp-scam-db/main.go index b776e9c..06c2d19 100644 --- a/cmd/mcp-scam-db/main.go +++ b/cmd/mcp-scam-db/main.go @@ -361,7 +361,7 @@ func runStdio(s *mcp.Server) error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/cmd/mcp-streetview/main.go b/cmd/mcp-streetview/main.go index 3b6ec20..48d073e 100644 --- a/cmd/mcp-streetview/main.go +++ b/cmd/mcp-streetview/main.go @@ -199,7 +199,7 @@ func runStdio(s *mcp.Server) error { if err != nil { return err } - session.Wait() + _ = session.Wait() return nil } diff --git a/internal/agent/subagents.go b/internal/agent/subagents.go index 1673fe6..da9823a 100644 --- a/internal/agent/subagents.go +++ b/internal/agent/subagents.go @@ -17,15 +17,15 @@ type ClientFn func(ctx context.Context, server string) (*mcpclient.Client, error // wired in the binary's main.go and share this struct. type MCPSubagent struct { NameStr string - Run_ func(ctx context.Context, sub Submission) []Fact + RunFn func(ctx context.Context, sub Submission) []Fact } func (m *MCPSubagent) Name() string { return m.NameStr } -func (m *MCPSubagent) Run(ctx context.Context, sub Submission) []Fact { return m.Run_(ctx, sub) } +func (m *MCPSubagent) Run(ctx context.Context, sub Submission) []Fact { return m.RunFn(ctx, sub) } -// runParallel is a convenience helper sub-agents use to call multiple +// RunParallel is a convenience helper sub-agents use to call multiple // MCP tools concurrently and append their results. -func runParallel(funcs ...func() []Fact) []Fact { +func RunParallel(funcs ...func() []Fact) []Fact { var ( mu sync.Mutex out []Fact diff --git a/internal/archival/timemachine/asof.go b/internal/archival/timemachine/asof.go index 17b8b95..5e79fc5 100644 --- a/internal/archival/timemachine/asof.go +++ b/internal/archival/timemachine/asof.go @@ -3,7 +3,10 @@ // monthly snapshots that follow it. package timemachine -import "time" +import ( + "fmt" + "time" +) // Query is the user-facing input. type Query struct { @@ -37,24 +40,5 @@ func (r Resolver) Locate(q Query) []string { } func monthKey(year int, m time.Month) string { - mm := int(m) - mmStr := "0" + string('0'+byte(mm)) - if mm >= 10 { - mmStr = string('0'+byte(mm/10)) + string('0'+byte(mm%10)) - } - return itoa(year) + "-" + mmStr -} - -func itoa(n int) string { - if n == 0 { - return "0" - } - var b [12]byte - i := len(b) - for n > 0 { - i-- - b[i] = byte('0' + n%10) - n /= 10 - } - return string(b[i:]) + return fmt.Sprintf("%d-%02d", year, int(m)) } diff --git a/internal/botcore/botcore_test.go b/internal/botcore/botcore_test.go index f97458b..6ebbaf5 100644 --- a/internal/botcore/botcore_test.go +++ b/internal/botcore/botcore_test.go @@ -52,7 +52,8 @@ func TestAPI_VerifyAndWait(t *testing.T) { func TestRateLimiter(t *testing.T) { rl := botcore.NewRateLimiter(2, time.Minute) - if !rl.Allow("a") || !rl.Allow("a") { + first, second := rl.Allow("a"), rl.Allow("a") + if !first || !second { t.Fatal("first two should pass") } if rl.Allow("a") { diff --git a/internal/compliance/pdpl/residency.go b/internal/compliance/pdpl/residency.go index 6abcd19..838212e 100644 --- a/internal/compliance/pdpl/residency.go +++ b/internal/compliance/pdpl/residency.go @@ -22,7 +22,7 @@ type TransferDecision struct { // Check returns whether data from country j may flow to destination. // Same-region transfers are always allowed. -func Check(j Jurisdiction, destinationRegion string) (TransferDecision, error) { +func Check(_ Jurisdiction, destinationRegion string) (TransferDecision, error) { if destinationRegion == "" { return TransferDecision{}, errors.New("destination region required") } diff --git a/internal/embassy/ui/kiosk.go b/internal/embassy/ui/kiosk.go index b56cb99..3d59036 100644 --- a/internal/embassy/ui/kiosk.go +++ b/internal/embassy/ui/kiosk.go @@ -39,7 +39,7 @@ func Handler(t *template.Template, page Page) http.Handler { if t == nil { t = template.Must(template.New("kiosk").Parse(kioskHTML)) } - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf-8") _ = t.Execute(w, page) }) diff --git a/internal/graphanalysis/components/cc.go b/internal/graphanalysis/components/cc.go index b47927c..3a4cada 100644 --- a/internal/graphanalysis/components/cc.go +++ b/internal/graphanalysis/components/cc.go @@ -13,8 +13,7 @@ func Find(nodes []string, edges []Edge) [][]string { for _, n := range nodes { parent[n] = n } - var find func(string) string - find = func(x string) string { + find := func(x string) string { for parent[x] != x { parent[x] = parent[parent[x]] x = parent[x] diff --git a/internal/graphanalysis/export/formats.go b/internal/graphanalysis/export/formats.go index 3020ada..5eaf167 100644 --- a/internal/graphanalysis/export/formats.go +++ b/internal/graphanalysis/export/formats.go @@ -38,10 +38,7 @@ func GraphML(w io.Writer, nodes []Node, edges []Edge) error { inner += `` enc := xml.NewEncoder(w) enc.Indent("", " ") - if err := enc.Encode(ml{Body: inner}); err != nil { - return err - } - return nil + return enc.Encode(ml{Body: inner}) } // Gephi writes a CSV-edge-list that gephi imports cleanly. diff --git a/internal/kg/builder/journalist.go b/internal/kg/builder/journalist.go index ac9d4fb..d0f0564 100644 --- a/internal/kg/builder/journalist.go +++ b/internal/kg/builder/journalist.go @@ -3,7 +3,7 @@ // lets the user fill in country/industry/date filters. package builder -import "fmt" +import "strings" // Starter is one pre-built query. type Starter struct { @@ -45,36 +45,7 @@ SELECT ?a ?b ?phone WHERE { func Fill(s Starter, args map[string]string) string { out := s.Query for k, v := range args { - out = replace(out, "{"+k+"}", v) + out = strings.ReplaceAll(out, "{"+k+"}", v) } return out } - -func replace(s, old, new string) string { - if old == "" { - return s - } - out := "" - for { - i := indexOf(s, old) - if i < 0 { - return out + s - } - out += s[:i] + new - s = s[i+len(old):] - } -} - -func indexOf(s, sub string) int { - if len(sub) == 0 { - return 0 - } - for i := 0; i+len(sub) <= len(s); i++ { - if s[i:i+len(sub)] == sub { - return i - } - } - return -1 -} - -func ensureFmt() string { return fmt.Sprintf("%s", "") } diff --git a/internal/kg/sparql/endpoint_test.go b/internal/kg/sparql/endpoint_test.go index 1f5079a..cfdaeac 100644 --- a/internal/kg/sparql/endpoint_test.go +++ b/internal/kg/sparql/endpoint_test.go @@ -9,7 +9,7 @@ import ( ) func TestRejectsEmptyQuery(t *testing.T) { - srv := httptest.NewServer(Endpoint{Execute: func(q string) ([]map[string]string, error) { return nil, nil }}) + srv := httptest.NewServer(Endpoint{Execute: func(_ string) ([]map[string]string, error) { return nil, nil }}) defer srv.Close() resp, _ := http.Get(srv.URL) if resp.StatusCode != http.StatusBadRequest { @@ -18,7 +18,7 @@ func TestRejectsEmptyQuery(t *testing.T) { } func TestStableSelectShape(t *testing.T) { - srv := httptest.NewServer(Endpoint{Execute: func(q string) ([]map[string]string, error) { + srv := httptest.NewServer(Endpoint{Execute: func(_ string) ([]map[string]string, error) { return []map[string]string{{"company": "ex:c1", "industry": "transport"}}, nil }}) defer srv.Close() diff --git a/internal/multitenant/onboarding/flow.go b/internal/multitenant/onboarding/flow.go index 738d62a..eb46e00 100644 --- a/internal/multitenant/onboarding/flow.go +++ b/internal/multitenant/onboarding/flow.go @@ -30,7 +30,7 @@ const ( // Required returns the KYC level for the country. NGO-led signups in // permissive jurisdictions only need a lite verification; commercial // recruiters always need full KYC. -func Required(country, role string) KYC { +func Required(_, role string) KYC { if strings.EqualFold(role, "commercial-recruiter") { return KYCFull } diff --git a/internal/personalization/cv/parse.go b/internal/personalization/cv/parse.go index 926bd0d..cc2887c 100644 --- a/internal/personalization/cv/parse.go +++ b/internal/personalization/cv/parse.go @@ -24,4 +24,4 @@ type Heuristic struct{} // Parse returns an empty profile. The agent treats an empty profile // as "no personalisation requested". -func (Heuristic) Parse(raw []byte, ct string) (Profile, error) { return Profile{}, nil } +func (Heuristic) Parse(_ []byte, _ string) (Profile, error) { return Profile{}, nil } diff --git a/internal/personalization/privacy/memonly.go b/internal/personalization/privacy/memonly.go index 034cc61..1b21c21 100644 --- a/internal/personalization/privacy/memonly.go +++ b/internal/personalization/privacy/memonly.go @@ -8,16 +8,21 @@ package privacy import "sync" -// Pool reuses byte slices so we can scrub them deterministically when -// they leave scope. -var Pool = sync.Pool{New: func() any { return make([]byte, 0, 4096) }} +// Pool reuses byte-slice buffers so we can scrub them deterministically +// when they leave scope. Buffers are stored by pointer so returning one +// to the pool does not allocate. +var Pool = sync.Pool{New: func() any { b := make([]byte, 0, 4096); return &b }} -// Scrub overwrites the slice with zeros and returns it to the pool. -func Scrub(b []byte) { - for i := range b { - b[i] = 0 +// Scrub overwrites the buffer with zeros and returns it to the pool. +func Scrub(b *[]byte) { + if b == nil { + return } - b = b[:0] + s := *b + for i := range s { + s[i] = 0 + } + *b = s[:0] Pool.Put(b) } diff --git a/internal/plugin/manifest_test.go b/internal/plugin/manifest_test.go index d5a5f99..fd97ef7 100644 --- a/internal/plugin/manifest_test.go +++ b/internal/plugin/manifest_test.go @@ -7,8 +7,9 @@ import ( "strings" "testing" - "github.com/yasserrmd/joblantern/internal/plugin" "gopkg.in/yaml.v3" + + "github.com/yasserrmd/joblantern/internal/plugin" ) func TestLoadManifest_OK(t *testing.T) { diff --git a/internal/redteam/adversarial/evade.go b/internal/redteam/adversarial/evade.go index aeb15ed..64c1b04 100644 --- a/internal/redteam/adversarial/evade.go +++ b/internal/redteam/adversarial/evade.go @@ -31,7 +31,9 @@ func (HomographSwap) Mutate(body string) string { type WhitespaceInject struct{} func (WhitespaceInject) Mutate(body string) string { - return strings.ReplaceAll(body, "WhatsApp", "What​sApp") + // Insert a zero-width space (U+200B) inside the trigger word so + // naive substring matching misses it. + return strings.ReplaceAll(body, "WhatsApp", "What\u200bsApp") } // All returns the canonical mutator chain. diff --git a/internal/redteam/generator/synthetic.go b/internal/redteam/generator/synthetic.go index 5327acd..fb64801 100644 --- a/internal/redteam/generator/synthetic.go +++ b/internal/redteam/generator/synthetic.go @@ -22,7 +22,7 @@ type Listing struct { // Defaults returns the seed list. Production generators expand from // templates per origin country and industry. -func Defaults(now time.Time) []Listing { +func Defaults(_ time.Time) []Listing { return []Listing{ {ID: "syn-1", Title: "URGENT Driver wanted Dubai", Body: "Pay AED 18000/mo. Apply via WhatsApp now.", Country: "AE", Industry: "transport", Phone: "+971-55-555-1111", GroundTruth: "scam"}, {ID: "syn-2", Title: "Nurse, KSA — bring passport copy", Body: "No interview needed. Visa on arrival.", Country: "SA", Industry: "health", GroundTruth: "scam"}, diff --git a/internal/rental/imagehash/phash.go b/internal/rental/imagehash/phash.go index 33fdcc7..cef0080 100644 --- a/internal/rental/imagehash/phash.go +++ b/internal/rental/imagehash/phash.go @@ -8,6 +8,7 @@ import ( "image" "image/color" "image/draw" + // Side-effect imports for image format decoding. _ "image/jpeg" _ "image/png" diff --git a/internal/researchapi/playground/handler.go b/internal/researchapi/playground/handler.go index 92274a4..6020b08 100644 --- a/internal/researchapi/playground/handler.go +++ b/internal/researchapi/playground/handler.go @@ -26,7 +26,7 @@ async function run(){ // Handler returns the explorer page. func Handler() http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf-8") _, _ = w.Write([]byte(page)) }) diff --git a/internal/researchapi/sdk/generate.go b/internal/researchapi/sdk/generate.go index 9fe25ab..a4d21a8 100644 --- a/internal/researchapi/sdk/generate.go +++ b/internal/researchapi/sdk/generate.go @@ -33,7 +33,7 @@ func python(baseURL string) string { var b strings.Builder b.WriteString("\"\"\"Joblantern research SDK (auto-generated).\"\"\"\n") b.WriteString("import urllib.request, json\n\n") - b.WriteString(fmt.Sprintf("BASE = %q\n\n", baseURL)) + fmt.Fprintf(&b, "BASE = %q\n\n", baseURL) b.WriteString("class Client:\n") b.WriteString(" def __init__(self, token=None):\n self.token = token\n\n") b.WriteString(" def _get(self, path, params=None):\n") @@ -51,7 +51,7 @@ func rLang(baseURL string) string { var b strings.Builder b.WriteString("# Joblantern research SDK (auto-generated)\n") b.WriteString("library(httr); library(jsonlite)\n\n") - b.WriteString(fmt.Sprintf("joblantern_base <- %q\n\n", baseURL)) + fmt.Fprintf(&b, "joblantern_base <- %q\n\n", baseURL) b.WriteString("joblantern_verdicts <- function(token=NULL, country=NULL, since=NULL, cursor=NULL) {\n") b.WriteString(" q <- list(country=country, since=since, cursor=cursor)\n") b.WriteString(" q <- q[!sapply(q, is.null)]\n") diff --git a/internal/web/recruiter.go b/internal/web/recruiter.go index f44793f..909b0dc 100644 --- a/internal/web/recruiter.go +++ b/internal/web/recruiter.go @@ -139,9 +139,10 @@ func (b *BadgeIssuer) svg(w http.ResponseWriter, r *http.Request) { return } colour := "#3da76a" - if c.Risk == "yellow" { + switch c.Risk { + case "yellow": colour = "#d6a23a" - } else if c.Risk == "red" { + case "red": colour = "#d6452a" } w.Header().Set("Content-Type", "image/svg+xml")