Skip to content

fix(codetype): support multiline and side-effect import detection - #69

Open
Adityakk9031 wants to merge 2 commits into
Corgea:mainfrom
Adityakk9031:fix/codetype-multiline-imports-detection
Open

fix(codetype): support multiline and side-effect import detection#69
Adityakk9031 wants to merge 2 commits into
Corgea:mainfrom
Adityakk9031:fix/codetype-multiline-imports-detection

Conversation

@Adityakk9031

Copy link
Copy Markdown
Contributor

Summary

  • Adds dot-all flag (?s)\ and non-greedy matching to the ES \import\ regex in \CodeTypeDetector::extract_imports\ so multiline import blocks are captured accurately.
  • Adds regex pattern support for side-effect imports (\import 'package').
  • Fixes false-positive Frontend classifications for Node/NestJS backend TypeScript files using multiline imports, which previously prevented backend security rules from loading.
  • Adds regression unit tests in \src/code_type_detector.rs.

@juangaitanv
juangaitanv self-requested a review August 17, 2026 08:32
Comment thread src/code_type_detector.rs Outdated
Comment thread src/code_type_detector.rs
regex::Regex::new(r#"import\s+.*from\s+['"]([^'"]+)['"]"#).unwrap(),
regex::Regex::new(r#"(?s)import\s+.*?from\s+['"]([^'"]+)['"]"#).unwrap(),
regex::Regex::new(r#"import\s*\(\s*['"]([^'"]+)['"]\s*\)"#).unwrap(),
regex::Regex::new(r#"import\s+['"]([^'"]+)['"]"#).unwrap(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a Go import such as github.com/reactivex/rxgo can match the react signature and override the Backend fallback; should we limit this extraction to applicable languages?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juangaitanv Thanks! Restricted extract_imports in src/code_type_detector.rs to JavaScript / TypeScript languages (javascript, typescript, tsx, jsx, js, ts), ensuring non-JS languages like Go or Python do not extract false JS framework signatures and cleanly retain their backend classification. Added regression test non_js_imports_do_not_override_backend_default.

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.

2 participants