Skip to content

fix: Address OCR L2 self-scan findings#1

Merged
raye-deng merged 3 commits intomainfrom
fix/ocr-self-scan-l2
Mar 10, 2026
Merged

fix: Address OCR L2 self-scan findings#1
raye-deng merged 3 commits intomainfrom
fix/ocr-self-scan-l2

Conversation

@raye-deng
Copy link
Copy Markdown
Owner

🛡️ OCR Self-Scan Report

This PR fixes issues identified by Open Code Review's own L2 analysis.

Scan Summary

  • Before: Score 67/100 (Grade D) — 113 issues
  • After: Score 67/100 (Grade D) — 111 issues
  • Issues fixed: 2 (Math.random() usage)

Changes

  • packages/core/src/license/generator.ts: Replace Math.random() with crypto.randomInt() for cryptographically secure license key generation (CWE-338)

Analysis of Remaining Issues

Most of the 111 remaining issues are false positives or architectural:

Category Count Notes
Implementation Quality 90 Complexity/nesting warnings — require architectural refactoring
Context Coherence 15 False positives: "unused interfaces" that ARE used locally
Code Freshness 8 False positives: deprecated API references in detector pattern data (not actual usage)

The score is dominated by Implementation Quality (0/20) which penalizes high cyclomatic complexity in parser files — these are inherent to regex-based language parsers and not practical to reduce without a full rewrite.

Evidence

This demonstrates OCR's self-scanning capability — eating our own dog food. The scan correctly identified a real security issue (Math.random() for key generation) while also revealing false positive patterns in detector/pattern files that we can improve in future versions.


Generated by Open Code Review L2 self-scan

Issues fixed from OCR L2 self-scan:
- Use cryptographically secure randomInt() instead of Math.random()
  for license key generation (CWE-338)
- Clarify re-export aliases in index.ts to avoid symbol collision warnings

Scan report: Score 67/100 → 67/100
(remaining issues are false positives from detector pattern data
and complexity warnings requiring architectural refactoring)
- Add JSDoc comments to exported interfaces
- Export ParsedLLMIssue, ImportOccurrence, and other types
- Minor type safety improvements
- Extract matchFunctionDeclaration() and extractBracedBody() helpers
  in duplication.ts to reduce nesting from 5 to 3
- Extract groupByFunctionName() and reportDuplicates() helpers
  in context-coherence.ts to reduce nesting from 5 to 3
- Before: 111 issues (67/100)
- After: 97 issues (67/100)
- Context Coherence improved: 15→3 issues
@raye-deng raye-deng force-pushed the fix/ocr-self-scan-l2 branch from 0eb66c0 to 3cc7536 Compare March 10, 2026 21:42
@raye-deng raye-deng merged commit 042b9cb into main Mar 10, 2026
1 of 2 checks passed
raye-deng added a commit that referenced this pull request Mar 18, 2026
…n detection

Quick Win #1: V4 hallucinated import detector now falls back to whitelist-based
detection when registry manager is unavailable (offline mode). Flags non-relative,
non-builtin imports with confidence 0.6.

Quick Win #3: Over-engineering detector now detects abstract classes and interfaces
with only one implementation — a common AI over-engineering pattern. Scans source
text for abstract class/interface definitions and their extends/implements relationships.

Both features include full test coverage.
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