Python fp and docs updtes (#58)

* refactor: Update comments for clarity and add expectations.json files for performance metrics

* feat: Implement FP guard for JS/TS local-collection receivers to suppress missing ownership checks

* feat: Enhance Rust parameter handling to classify local collections and prevent false ownership checks

* refactor: Simplify code formatting for better readability in multiple files

* refactor: Improve UTF-8 sequence length handling and enhance clarity in loop iteration

* feat: Update Java and Python patterns to include new security rules

* refactor: Improve comment clarity and consistency across multiple Rust files

* refactor: Simplify code formatting for improved readability in integration tests and module files

* refactor: Improve comment formatting and enhance clarity in assertions across multiple files
This commit is contained in:
Eli Peter 2026-04-29 19:53:34 -04:00 committed by GitHub
parent 4db0805de6
commit a438886217
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
291 changed files with 9485 additions and 3851 deletions

View file

@ -0,0 +1,41 @@
// FP guard / panic guard — CFG condition-text truncation must be UTF-8 safe.
//
// Reproduces the gogs scan crash where a CodeMirror Gherkin tokenizer ships a
// long localised regex inside a boolean sub-condition (`stream.match(/.../) &&
// other`). When `push_condition_node` textualises the sub-expression, the
// regex literal exceeds MAX_CONDITION_TEXT_LEN (256 bytes); naive byte-slice
// truncation panicked when byte 256 landed inside a multi-byte UTF-8
// character (here Gurmukhi `ਖ`, three bytes). Engine fix in
// `src/utils/snippet.rs::truncate_at_char_boundary`, applied at three CFG
// sites + two symex display sites.
//
// Invariant: scanning this file must terminate without panicking the rayon
// worker, regardless of where byte 256 lands.
function tokenLocalisedFeatureKeyword(stream, state) {
if (
!state.inKeywordLine &&
state.allowFeature &&
stream.match(/(機能|功能|フィーチャ|기능|โครงหลัก|ความสามารถ|ความต้องการทางธุรกิจ|ಹೆಚ್ಚಳ|గుణము|ಮುಹಾಂದರಾ|ਮੁਹਾਂਦਰਾ|ਨਕਸ਼ ਨੁਹਾਰ|ਖਾਸੀਅਤ|रूप लेख|وِیژگی|خاصية|תכונה|Функціонал|Функция|Функционалност|Функционал|Үзенчәлеклелек|Свойство|Особина|Мөмкинлек|Могућност|Λειτουργία|Δυνατότητα|Właściwość|Vlastnosť|Trajto|Tính năng|Savybė|Požiadavka|Požadavek|Potrzeba biznesowa|Özellik|Osobina|Ominaisuus|Omadus|Mogućnost|Mogucnost|Jellemző|Funzionalità|Funktionalitéit|Funktionalität|Funkcja|Funkcionalnost|Funkcionalitāte|Funkcia|Fungsi|Functionaliteit|Funcționalitate|Funcţionalitate|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Fīča|Feature|Eiginleiki|Egenskap|Egenskab|Característica|Caracteristica|Business Need|Aspekt|Arwedd|Ability):/)
) {
state.inKeywordLine = true;
return "keyword";
}
return null;
}
// Sanity: also exercise the let-match-guard truncation site
// (`emit_rust_match_guard_if`) by way of a JS analogue with a CFG-relevant
// boolean chain that wraps localised text into the second branch. The CFG
// builder still has to textualise both arms.
function classify(s) {
if (
s.length > 0 &&
s.indexOf("ਨਕਸ਼ ਨੁਹਾਰ ਖਾਸੀਅਤ रूप लेख وِیژگی خاصية תכונה Функціонал Функция Функционалност Функционал Үзенчәлеклелек Свойство Особина Мөмкинлек Могућност Λειτουργία Δυνατότητα") >= 0
) {
return "localised";
}
return "ascii";
}
module.exports = { tokenLocalisedFeatureKeyword, classify };

View file

@ -0,0 +1,14 @@
{
"required_findings": [],
"forbidden_findings": [],
"noise_budget": {
"max_total_findings": 0,
"max_high_findings": 0
},
"performance_expectations": {
"max_ms_no_index": 1000,
"max_ms_index_cold": 1500,
"max_ms_index_warm": 500,
"ci_mode": "lenient"
}
}