Repository navigation
#8999 Refactor: Polynomial regular expression used on uncontrolled data - #9000
Merged
AlexeyGirin merged 2 commits intoJan 26, 2026
Merged
Conversation
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor polynomial regular expression for better performance
Harden SGroup trailing whitespace trim to avoid regex backtracking
Jan 24, 2026
AlexeyGirin
marked this pull request as ready for review
January 24, 2026 11:58
auto-assign
Bot
requested review from
NataliaLoginova,
Zhirnoff and
rrodionov91
January 24, 2026 11:58
rrodionov91
approved these changes
Jan 26, 2026
AlexeyGirin
added a commit
that referenced
this pull request
Feb 28, 2026
…ta (#9000) * Initial plan * Replace regex trimRight with trimEnd Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
AlexeyGirin
added a commit
that referenced
this pull request
Feb 28, 2026
* Fixed flaky tests * fixes * f2 * Update Node.js baseline to 22 (#9026) * Initial plan * update node version references Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * #8999 Refactor: Polynomial regular expression used on uncontrolled data (#9000) * Initial plan * Replace regex trimRight with trimEnd Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * #9003 Refactor: React Router vulnerable to XSS via Open Redirects (#9004) * Initial plan * chore: update react-router to 7.13.0 Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * #9005 Refactor: Next library has a Denial of Service with Server Components - Incomplete Fix Follow-Up (#9006) * Initial plan * chore: upgrade next/react for example-ssr Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * #8987 Labels for monomer natural analog category is missing if filter applied (#8992) * Initial plan * fix: always show monomer group titles in RNA accordion Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * limit natural analog titles to relevant monomer groups Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * fixes --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> Co-authored-by: Alexey Girin <alexey_girin@epam.com> * #9011 Refactor: qs arrayLimit bypass mitigation via parent dependency updates (#9015) * Initial plan * Update qs and body-parser overrides Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Update body-parser via parent dependency Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * #9016 Refactor: update js-yaml dependencies to patched versions without overrides (#9019) * Initial plan * chore: override js-yaml to patched versions Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * chore: bump js-yaml patch versions Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * chore: remove js-yaml overrides and update lock Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Align S-Group subtype combobox width and default option visibility (#8979) * Initial plan * Align S-Group subtype combobox width with other selects Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * fix: show selected empty subtype option Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * fixes * - fixed non specified value * - fixed unit tests * fixes --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> Co-authored-by: Alexey Girin <alexey_girin@epam.com> Co-authored-by: Roman Rodionov <roman_rodionov@epam.com> * Refactor: Potential fix for code scanning alert no. 22: Unvalidated dynamic method call (#9001) * Potential fix for code scanning alert no. 22: Unvalidated dynamic method call Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Fix unvalidated dynamic method call in parseSGroup.js (#9002) * Initial plan * Fix unvalidated dynamic method call in parseSGroup.js Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Optimize security fix by moving constants outside function scope Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * #9022 Refactor: PostCSS line return parsing error (#9023) * Initial plan * chore: fix package.json trailing comma Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * chore: remove postcss override Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Update CI to Node.js 22.11 (#9037) * #9032 - Flex mode icon is active after ketcher close and open again (#9049) (#9052) * #9032 - Flex mode icon is active after ketcher close and open again - added reset mode button state to default on destroy * - updated ketcher version to 3.12.0-rc.2 (cherry picked from commit d721b77) * #9047 - Leaving group atom position is incorrect for nucleotides created in monomer wizard (#9048) (#9051) - fixed leaving group atom position for nucleotides in monomer creation wizard (cherry picked from commit 34ad31d) * #7153 - Molecule from expanded monomer disappars on switching to Macromolecules mode (#8989) * fix dissapearing molecule from expanded monomer * fixed build * create fragment after removing s group * fixed build * removed redundant * added comment * #8974 autotests for ketcher 3110 bugs (#9031) * add cases * add cases and files * update code and screenshoots * remove step about screenshoot * changes after review * some changes for wariningMessageDialog * add changes * add changes after review * Autotests: 8331 autotests axolabs format support (#8339) * First * second * #9065 System shows natural analog category for phosphates (#9066) * Initial plan * chore: plan phosphate category fix Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * fix: hide phosphate natural analogue groups Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * fixes * f2 * f3 * revert: restore RNA phosphate grouping Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * chore: revert package-lock.json Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * fixes * f2 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> Co-authored-by: Alexey Girin <alexey_girin@epam.com> * Add fragment selection tool and rename structure selection tooltip (#8973) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> Co-authored-by: Roman Rodionov <roman_rodionov@epam.com> * Backmerge: #9078 - Update the help document (3.12.) (#9079) * Delete documentation/images/S-Group-Properties-3.6.png * Add files via upload * Update help.md * #9084 - Ketcher saves incorrect attachment points configuration for new nucleotides (#9086) (#9088) (cherry picked from commit 5177c79) * - fixed vulnerability (#9100) * #7915 autotests enable flipping of all expanded monomers in a structure (#9083) * add test cases * add description for tests * #8254 Allow for stereo-bonds (up and down) to be a bond between AA and LGA (#9080) * add test cases * add changes * add svg format for macro * add description for the tests * Update the layout method * # 8383 Introduce library searching using HELM aliases, AxoLabs aliases, and modification types (#9059) * add test cases * update screenshoots * add description for tests * update code and screenshot * #9098 autotests alignment of sense and antisense strings in axolabs format (#9101) * add cases * add screenshots and tests * Changed call for page to the BeforeAll fixture. Stabled some flacky tests (#9107) * add cases (#9112) * #9113 The Copolymer S-Group type should not be displayed unless there are at least two structural repeating units (SRUs) in selection (#9117) * Initial plan * Plan for copolymer s-group availability Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Restrict copolymer s-group option Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Address code review feedback Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Refine copolymer option checks Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Simplify copolymer option logic Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Polish copolymer option filtering Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Tighten copolymer availability check Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Trim sgroup memo dependencies Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Simplify copolymer scheme selection Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Type annotate sgroup test helper Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Memoize schemes and count SRUs Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * #7492 - autotests transform isolated test execution to clear canvas test execution for undo redo actionsspects (#9131) * Isolated test execution has been transformed to clear canvas test execution for undo redo actions. * Screenshots updated * #7493 Transformed isolated test execution to clear canvas test execution for right-click.spec.ts (#9133) * #9119 add expects and change repeating code (#9128) * add expects and change repeating code * add changes for failed test * #9108 Incorrect valence for nitrogen (#9124) * Initial plan * Allow nitrogen valence 5 Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * fixes --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> Co-authored-by: Alexey Girin <alexey_girin@epam.com> * #9126 Some keyboard shortcuts don't work on Macromolecules canvas (#9127) * Initial plan * Fix macromolecules hotkeys Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Adjust macromolecule hotkey tests Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Clarify sequence-mode hotkey comment Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Document bond hotkey options Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Refactor bond hotkey helper Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Tidy hotkey comments Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Revert macromolecule hotkey tests Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Fixes --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> Co-authored-by: Alexey Girin <alexey_girin@epam.com> * refactor: reEmage and resimpleObject toggle points logic (#9222) * 9151:constructor should have readonly (#9241) * refactor:use nullish coeliscine (#9242) * Fix attachment point sorting comparator (#9281) * Fix reduce call in DistanceSnapView with initial value (#9268) * test: document intentional noop helper (#9264) * fix(core): avoid unused ClearTool instantiation in test (#9206) * Fix dialog keyboard handler accessibility issue (#9200) * fix(core): make EmptySnakeLayoutNode non-empty (#9265) * #9227 - The return value of "useState" should be destructured and named symmetrically (#9228) * Initial plan * Fix useState asymmetric naming: rename isStuctureChecking to isStructureChecking Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * #9223- Redundant casts and non-null assertions should be avoided (#9224) * Initial plan * Remove redundant TypeScript casts and non-null assertions Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * Fix type errors: properly handle false values and keep necessary cast Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * #9223- remove redundant type assertion for actionmenu --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * #9217 - React props should be read-only (#9219) * Initial plan * Make React props read-only in 5 components Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * Remove package-lock.json from commit * Remove package-lock.json from commit Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * Restore package-lock.json to original state --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * #9211 - Switch cases should end with an unconditional "break" statement (#9212) * Initial plan * Initial analysis - identify switch case fall-through issues Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * Fix switch case fall-through in action/index.js and state/index.js Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * Refactor to reduce code duplication in switch cases Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * Add JSDoc and improve variable naming Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * Revert "Initial analysis - identify switch case fall-through issues" This reverts commit 2286028. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * #9259 - If statements should not be the only statement in else blocks (#9261) * Initial plan * Refactor: Replace nested if in else block with else if in CoreAtom.ts Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * #9293 Autotests: Cyclic imports in autotests (#9294) * Initial plan * fix(autotests): remove circular imports in tests utilities and monomer dialog Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * refactor(autotests): eliminate remaining cyclic imports in tests Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * refactor(autotests): rollback requested files and replace delay helper calls Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * fixes * f2 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> Co-authored-by: Alexey Girin <alexey_girin@epam.com> * #9251 - Redundant React fragments should be removed (#9252) * Initial plan * Remove redundant React fragment in ErrorsCheck component Co-authored-by: oguzhanduran <86467364+oguzhanduran@users.noreply.github.com> * Remove package-lock.json changes from PR Co-authored-by: oguzhanduran <86467364+oguzhanduran@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: oguzhanduran <86467364+oguzhanduran@users.noreply.github.com> * #9236 - Ternary operators should not be nested (#9247) * Initial plan * Refactor nested ternary operators in 4 files Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * 9236 - undo changes for package-lock * 9236 - refactor nested arrays for period table * 9236 - extract modification type attribute logic to reusable utility --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * 9167:fixed all branches in a conditional structure should not have exactly same implementation issue (#9230) * #9193:Refactor:(TypeScript) Objects and classes converted or coerced t… (#9196) * 9183:Refactor:(TypeScript) Objects and classes converted or coerced to strings should define * 9183/fix:delete unnecessary file * 9183/refactor:fix according to copilot review comment * fix:remove unused function * 9279: create cross-platform script for app build and run (#9280) * #9298: (TypeScript) Two branches in a conditional structure should not have exactly the same implementation (#9300) * refactor:implement duplicate branch cleanup in 2 reported lications * Revert "refactor:implement duplicate branch cleanup in 2 reported lications" This reverts commit 95dabd1. * refactor two branches same implementations * #9207- Unused React typed props should be removed (#9214) * 9207/fix:remove unused props * fix:refactor accroding comments * fix:rename current to diaog element * #9195 - Refactor: Use optional chaining instead of manual null checks (#9201) * Initial plan * Refactor: Use optional chaining instead of manual null checks Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * Fix prettier formatting issues Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * Fix code review issues: correct atom lookup and improve if statement logic Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * #9195 fix test issues * #9195 fix undo changes for package-lock * 9195 - replace undefineds with null * #9195 - replace null with undefined * #9195 - replace some undefineds with null --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * #9238 - Refactor: (TypeScript) Non-interactive DOM elements should not have interactive ARIA roles (#9262) * Enhance accessibility by adding ARIA roles and attributes to various components * Refactor ARIA roles to improve accessibility and semantic structure in ColorPicker, Form components, and SpecialSymbolsButton * Refactor ColorPicker to streamline ID generation for palette * fix snapshots * 9174: fix selector duplicated issue (#9302) * #9255 - Spacing between inline elements should be explicit (#9256) * Initial plan * Fix ambiguous JSX whitespace in RnaPresetTabs.tsx Co-authored-by: oguzhanduran <86467364+oguzhanduran@users.noreply.github.com> * Use explicit JSX space expression {' '} as per lint rule Co-authored-by: oguzhanduran <86467364+oguzhanduran@users.noreply.github.com> * Format JSX space expression on single line as per image Co-authored-by: oguzhanduran <86467364+oguzhanduran@users.noreply.github.com> * Use regular space instead of {' '} JSX expression Co-authored-by: oguzhanduran <86467364+oguzhanduran@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: oguzhanduran <86467364+oguzhanduran@users.noreply.github.com> * 9162 used collection contents (#9208) * #9209 - Refactor: (JavaScript) Loop counters should not be assigned within the loop body (#9237) * Refactor loop structures to use while instead of for for improved readability in utils.js and v3000.js * Refactor spacebarsplit function for improved readability and maintainability * refactor: update according to Sonar errors (#9272) * #9160-(TypeScript) Unused assignments should be removed (#9226) * 9160/refactor:remove unused assignments * 9160/refactor:remove unused assignments * 9160/refactor:try to pass test in github * remove ubused assignments * fix:remove unnnessacary changes from structeditor * fix:revert * remove unused assigments * refactor:use lodash for form and structeditor * #8187 It is possible to create preset with empty name (#9075) * Initial plan * fix: reject empty monomer group template names Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * fix: keep preset template updates while validating names Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * test: cover whitespace-only preset names Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * fix: clarify empty preset name error text Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * #9276- Literals should not be used for promise rejection #9276iterals should not be used for promise rejection (#9277) * 9276: fix promise rejection for literal usage * normalizeError utility added * added normalizeError utility into all necessary files * #9269: add anput references to labels for iframe in examples (#9275) * refactor: simplify async handling in cut and keydown event methods (#9305) * Support for enhanced stereochemistry markings in macromolecules mode (#9095) * Initial plan * Add stereoLabel support to CoreAtom and AtomRenderer for macromolecules mode Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Fix magic number in positionStereoLabel method Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * fixed size of stereolabel * fixed displaying abs stereoflags * fixed moving stereolabel after moving second bonds atom --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> Co-authored-by: Aleksei Proskurnov <proskurn@gmail.com> * #9282 - Empty collections should not be accessed or iterated (#9284) * Fix empty collection access in sequence tests and sgroup action * Fix: Always initialize `attachmentPoints` as an empty array, disregarding `attrs.attachmentPoints`. * #9218 - Unused methods of React components should be removed (#9221) * refactor analyse dialog to remove unused class methods * refactor: move analyseItems constant outside of Analyse component to prevent re-declaration * #9202 - Make EditorHistory constructor private and add getInstance accessor (#9213) * Fix EditorHistory constructor return by using static accessor * fix: Disable `no-use-before-define` ESLint rule for the `_instance` property. * style: format EditorHistory.update arguments for improved readability. * refactor: improve type safety of EditorHistory singleton by adding an instance type guard. * Update auto_assign.yml to simplify assignee groups (#9270) Removed developers and QA groups from auto assign configuration. * #8896- fix assertion error when adding ket file to canvas (#9315) * #9260 - Refactor: Constructors should not contain asynchronous operations (#9296) * Initial plan * refactor: move async monomers library init out of CoreEditor constructor Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * #9260 - undo the changes on package-lock --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> * Introducing rotation of monomers in Macromolecules mode (#9094) * Initial plan * Add rotation and flip functionality for monomers in Macromolecules mode Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Add interactive rotation handle functionality with 15° snapping Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> * Address code review feedback: extract constants, improve comments Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> Co-authored-by: Roman Rodionov <roman_rodionov@epam.com> * fixes * f2 * f3 * f5 * f6 --------- Co-authored-by: Ieva Bendikiene <bendikiene16@gmail.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com> Co-authored-by: Roman Rodionov <roman_rodionov@epam.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: aproskurnov <proskurn@gmail.com> Co-authored-by: AnnaKosol <annakosolapova24@gmail.com> Co-authored-by: Ljubica Milovic <ljubica_milovic@epam.com> Co-authored-by: Pavel Lukin <124054458+zefiris87@users.noreply.github.com> Co-authored-by: Yaroslav Kovalsky <71060724+YatsekTest@users.noreply.github.com> Co-authored-by: SergeiBakirov <sergei_bakirov@epam.com> Co-authored-by: Yurii Danylenko <Givchik228@gmail.com> Co-authored-by: Gulia <83670176+guliaisaeva@users.noreply.github.com> Co-authored-by: azamatalt <108387789+azamatalt@users.noreply.github.com> Co-authored-by: beyzaevcen <95762073+beyzaevcen@users.noreply.github.com> Co-authored-by: oguzhanduran <86467364+oguzhanduran@users.noreply.github.com> Co-authored-by: Yurii Danylenko <yurii_danylenko@epam.com> Co-authored-by: umutzd-alt <umutozdemir997@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
How the feature works? / How did you fix the issue?
The SGroup parser trimmed trailing whitespace using a regex with backtracking risk on uncontrolled MOL data. The trim now uses a native method without regex backtracking while preserving existing behavior.
/\s+$/withtrimEnd()intrimRight.Check list
#1234 – issue nameOriginal prompt
This section details on the original issue you should resolve
<issue_title>Refactor: Polynomial regular expression used on uncontrolled data</issue_title>
<issue_description>Problem location: packages/ketcher-core/src/domain/serializers/mol/parseSGroup.js:365
Description
Some regular expressions take a long time to match certain input strings to the point where the time it takes to match a string of length n is proportional to nk or even 2n. Such regular expressions can negatively affect performance, or even allow a malicious user to perform a Denial of Service ("DoS") attack by crafting an expensive input string for the regular expression to match.
The regular expression engines provided by many popular JavaScript platforms use backtracking non-deterministic finite automata to implement regular expression matching. While this approach is space-efficient and allows supporting advanced features like capture groups, it is not time-efficient in general. The worst-case time complexity of such an automaton can be polynomial or even exponential, meaning that for strings of a certain shape, increasing the input length by ten characters may make the automaton about 1000 times slower.
Typically, a regular expression is affected by this problem if it contains a repetition of the form r* or r+ where the sub-expression r is ambiguous in the sense that it can match some string in multiple ways. More information about the precise circumstances can be found in the references.
Recommendation
Modify the regular expression to remove the ambiguity, or ensure that the strings matched with the regular expression are short enough that the time-complexity does not matter.
Example
Consider this use of a regular expression, which removes all leading and trailing whitespace in a string:
The sub-expression
"\s+$"will match the whitespace characters in text from left to right, but it can start matching anywhere within a whitespace sequence. This is problematic for strings that do not end with a whitespace character. Such a string will force the regular expression engine to process each whitespace sequence once per whitespace character in the sequence.This ultimately means that the time cost of trimming a string is quadratic in the length of the string. So a string like
"a b"will take milliseconds to process, but a similar string with a million spaces instead of just one will take several minutes.Avoid this problem by rewriting the regular expression to not contain the ambiguity about when to start matching whitespace sequences. For instance, by using a negative look-behind (
/^\s+|(?<!\s)\s+$/g), or just by using the built-in trim method (text.trim()).Note that the sub-expression
"^\s+"is not problematic as the^anchor restricts when that sub-expression can start matching, and as the regular expression engine matches from left to right.Example
As a similar, but slightly subtler problem, consider the regular expression that matches lines with numbers, possibly written using scientific notation:
The problem with this regular expression is in the sub-expression
\d+E?\d+because the second\d+can start matching digits anywhere after the first match of the first \d+ if there is no E in the input string.This is problematic for strings that do not end with a digit. Such a string will force the regular expression engine to process each digit sequence once per digit in the sequence, again leading to a quadratic time complexity.
To make the processing faster, the regular expression should be rewritten such that the two
\d+sub-expressions do not have overlapping matches:^0\.\d+(E\d+)?$.Example
Sometimes it is unclear how a regular expression can be rewritten to avoid the problem. In such cases, it often suffices to limit the length of the input string. For instance, the following regular expression is used to match numbers, and on some non-number inputs it can have quadratic time complexity:
It is not immediately obvious how to rewrite this regular expression to avoid the problem. However, you can mitigate performance issues by limiting the length to 1000 characters, which will always finish in a reasonable amount of time.
References
OWASP: Regular expression Denial of Service - ReDoS.
Wikipedia: ReDoS.
Wikipedia: Time complexity.
James Kirrage, Asiri Rathnayake, Hayo Thielecke: Static Analysis for Regular Expression Denial-of-Service Attack.
Common Weakness Enumerat...
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.