Add CVODES forward sensitivity integration, fix FD bump default, and merge C prototype fixes - #322
Open
akutuva21 wants to merge 90 commits into
Open
Add CVODES forward sensitivity integration, fix FD bump default, and merge C prototype fixes#322akutuva21 wants to merge 90 commits into
akutuva21 wants to merge 90 commits into
Conversation
…NG2.pl
Replaced string eval instantiation (`eval '$model = new '.$options->config->{ModelID};`) with direct class instantiation (`my $model_class = $options->config->{ModelID}; $model = $model_class->new();`) to prevent arbitrary code execution vulnerabilities.
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
1) Rewrote `MacroBNGModel::replaceAll` in C++ to use `reserve` and `append` instead of in-place `replace`. 2) Converted several generator expressions in Python `.join()` calls to list comprehensions. 3) Fixed an invalid argument pass to `dict()` in `bpgMaps.py`. Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
…6731269290707 🛡️ Sentinel: [CRITICAL] Fix command injection vulnerability in MacroBNG2.pl
…2749036622 ⚡ Bolt: Optimize string replacement and Python joins
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
…743183774 ⚡ Bolt: Optimizing dictionary creation and XML parsing loops
Replaces hardcoded FALSE parameter with actual loopcount()>0 check when calling fcanonise in addedgeg.c, deledgeg.c, and newedgeg.c. Fixes longstanding FIXME (loops) bug.
Three fixes: (1) Writes output headers for SPARSE6/GRAPH6 when filtering in pickg, (2) Changes USERDEF return type from int to long, (3) Renames getline to nauty_getline to avoid POSIX conflict.
Replaces TODO stub with actual implementation that delegates to the sub-expression's toMathMLString method, passing through plist and indent parameters.
Changes the USERDEF function signature from int to long in bng-graph/nauty/nauty24/testg.c. (src/nauty version already handled in #381.)
Replaces list comprehensions inside str.join() with generator expressions to avoid creating intermediate lists.
Replaces list(dict.items()) + list(dict2.items()) with itertools.chain() to avoid creating intermediate lists.
Caches repeated XML element .get() calls in local variables for createMolecule and related functions.
Replaces repeated dict[key] lookups with .get() to reduce dict accesses.
Hoists repeated division by (j+1) outside the inner loop.
Adds 105-line test suite for BnglWriter covering basic serialization, parameter writing, species, rules, and observables.
Adds 42-line test for SpeciesList covering creation with checkIso disabled and pattern graph operations.
Adds tests for checkNegativePopulations covering positive, near-negative, and threshold-negative populations.
Adds CppExportWriter tests. Removes stale CMakeLists.txt.patch.
Adds edge case tests for isIsomorphic.
Replaces TODO stub in CPY file header with working Python ctypes usage example showing how to call the generated .so library.
Removes the parameter that was being passed through toCVodeString and toMatlabString but never used. The RxnRule RRefs lookup was marked as 'may be obsolete'.
Removes large commented-out code blocks in RxnRule.pm that were explicitly noted as 'Removed by Justin -- being permissive about species syntax'.
- Created `tests/test_ssc_writer.cpp` covering parameter and species formatting. - Added tests for numeric and non-numeric rate laws with statistical factors. - Verified removal of local scope directives from rate laws. - Updated `tests/CMakeLists.txt` to include the new test executable. Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
…p arguments in NFSim dispatcher (#434) Added numeric and path validations for arguments passed to execvp when invoking NFSim. This prevents a malicious user from providing a crafted unverified path or flags that could result in arbitrary code execution. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Added testing for `updateObservables` in `tests/test_pla_simulator.cpp`. Added proxy helper functions `setupDummyGroups` and `updateObservables` to `PlaSimulatorTestProxy` to allow interaction and initialization with private members and correctly execute the function. This covers normal observable calculation across standard state elements and boundary empty state vectors. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
…ngRule Optimizes regex compilation by making regex objects static const in MacroBNGModel.cpp and PopulationMappingRule.cpp. Also fixes duplicate Catch2 test names and adds bng_parser link to test builds. Additionally fixes C23 compatibility issues in Network3 mathutils: - Add proper prototypes for all BLAS/LAPACK extern declarations (ddot, dgemm, dgemv, etc.) - Fix implicit int in test file main() functions
Fixes command injection vulnerability in Perl scripts by converting 2-argument open() to 3-argument open(). Also fixes C23 compatibility issues in Network3 mathutils (BLAS/LAPACK prototypes, implicit int).
…rtiteGraph parser (#446) * ⚡ Bolt: [performance improvement] Optimize dictionary lookups in BipartiteGraph parser 💡 What: Replaced generator expressions using `.items()` and linear scans with `dict.keys()` or pre-computed mapping dictionaries in hot paths within `bipartiteGraph.py` and `bpgMaps.py`. Pre-calculated string conversions inside the `NameDictionary` class constructor to enable constant time O(1) lookups in `getIdx` and `getElement` instead of repetitive O(N) operations. 🎯 Why: Generator expressions over dictionary items and repetitive linear scans inside tight loops created significant performance overhead and slowed down the parser during mapping. Lookups based on O(N) operations cause slow parsing when the graph involves numerous patterns and transformations. By reducing the time complexity to O(1) with cached hash map operations, graph generation and transformations become significantly faster. 📊 Impact: Reduces time complexity in graph lookups from O(N) to O(1) for name, index, and element resolution. Mitigates unnecessary generator/iteration allocations in Python, particularly affecting large graph parsings and XML conversions. 🔬 Measurement: Run the test suite or execute `bipartiteGraph.py` on large rulesets and observe the faster conversion rates, as redundant iterations during graph traversal and node/edge parsing have been eliminated. Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com> * Delete .jules/bolt.md --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
…id regex dynamically compilation overhead (#447) 💡 What: Optimized `hasModifier` by avoiding string allocations for lowercase conversions, utilizing an inline iterator-based case-insensitive string equality comparison instead. Also avoided regex dynamic compilation inside tight loops in `MacroBNGModel::del_blank` and `MacroBNGModel::pre_species1` by using `std::string` manual parsing instead of `std::regex`. 🎯 Why: In `hasModifier`, string creation and transformation inside loops created unnecessary heap allocation and redundant iteration overhead. Similarly, `std::regex` compilation incurs a heavy performance drain when repeatedly compiling inside loops (such as regex strings in `re_paren` and `re_leading_num`). 📊 Impact: Reduces repetitive string operations in modifier checks and bypasses expensive dynamic regex compilation overhead in parsing. 🔬 Measurement: Compile the C++ binaries and execute tests natively using `make benchmark` and `make test`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
…string operations in parsing loops (#448) Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
…roBNGModel.pm 🚨 Severity: CRITICAL 💡 Vulnerability: 2-argument open() in Perl allows for unintended path manipulations or command injection if inputs are not fully sanitized. 🎯 Impact: Could allow execution of arbitrary shell commands or access to unintended files if filenames contain shell characters. 🔧 Fix: Replaced with safer 3-argument open(), and cleaned up prefix variable strings containing hardcoded modes. ✅ Verification: Verified script syntax and ran the BNG test suite. Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
…ns are out of scope for this sentinel security fix)
What: Converted insecure 2-argument open() calls in Perl scripts to the secure 3-argument format. Risk: 2-argument open() is vulnerable to file path and command injection. Solution: Used open(FH, "<", $file) or open(FH, ">", $file) consistently. Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
- Remove .jules/sentinel.md (Jules learning file) - Remove parse_open*.py, test_eval.pl (discovery scripts, not part of fix) - Revert MacroBNGModel.pm changes (duplicated by PR #450) - Revert MacroBNGModel.cpp changes (out-of-scope regex optimization) Keep BNGAction.pm, Boolean2BNGL.pl, VisOptParse.pm 2-arg open fixes.
…roBNGModel.pm 🛡️ Sentinel: [CRITICAL] Fix Path Injection via 2-Argument Open in MacroBNGModel.pm
🛡️ Sentinel: [HIGH] Fix 2-argument open() vulnerabilities
…insensitive matching
…insensitive matching ⚡ Bolt: Replace std::transform allocations with zero-allocation case-insensitive matching
…s in compilation loops
…s in compilation loops ⚡ Bolt: [performance improvement] Optimize string case-transformations in compilation loops
…:string finding in MacroBNGModel
…:string finding in MacroBNGModel ⚡ Bolt: [performance improvement] Replace slow regex with manual std::string finding in MacroBNGModel
…s to avoid O(N*M) conversions What: Pre-compute lowercase model function names outside reaction loop and inline case conversion for rawRateLaw. Risk: Low Solution: Avoids expensive std::tolower operations on strings during OdeIntegrator compilation. Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Pre-compute lowercase model function names outside reaction loop and inline case conversion for rawRateLaw. Avoids expensive std::tolower operations on strings during OdeIntegrator compilation.
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.
Summary
method=cvodesforLinearParameterSensitivityaction, enabling efficient forward-mode sensitivity analysis via SUNDIALS CVODESextern "C"wrappers for C++ compat, andmain(void)to BLAS/LAPACK declarations throughoutbng2/Network3/src/util/mathutils/dieincorrectly referenced$netfileinstead of$rabfile)