231 Commits

Author SHA1 Message Date
fab
870da8e1c9
Merge pull request #11 from fabriziosalmi/codeflash/optimize-validate_regex-m6xp4bpf
️ Speed up function `validate_regex` by 2,003%
2025-02-09 15:14:42 +01:00
fab
fb284892f1
Merge pull request #12 from fabriziosalmi/codeflash/optimize-sanitize_pattern-m6xp6cvk
️ Speed up function `sanitize_pattern` by 11,547%
2025-02-09 15:14:24 +01:00
codeflash-ai[bot]
17faa1f1b9
️ Speed up function sanitize_pattern by 11,547%
I've analyzed the script provided and I'll make some optimizations to improve its runtime performance while ensuring the functionality remains the same. Let's break it down step-by-step.

### Improvements.
1. **Avoid Redundant Checks:** Optimize by eliminating unnecessary repetitive checks.
2. **Combining String Operations:** Combine string operations to minimize calls.
3. **Caching Compiled Patterns:** If re.escape or re.compile are used multiple times for the same pattern, cache the results to avoid recomputing them.

Here’s the optimized version of the script.



### Summary of changes.
1. **LRU Caching**.
   - Used `functools.lru_cache` to cache results of `_compile_pattern` and `_sanitize_pattern` for improved performance on repetitive calls.
2. **Removed Redundant Condition**.
   - Moved repeated checks and operations within a single `if` block to simplify the flow and eliminate unnecessary calls.
3. **Centralized Pattern Validation**.
   - Centralized the regex validation and escaping in `_sanitize_pattern` function to minimize redundancy.

These changes should optimize your program's performance by reducing redundant computations and leveraging caching mechanisms. The functionality remains unchanged and will return the same values as before.
2025-02-09 14:06:18 +00:00
codeflash-ai[bot]
a54f33e097
️ Speed up function validate_regex by 2,003%
### Explanation.

1. **Caching with lru_cache**.
   - By using `functools.lru_cache`, the function `validate_regex` now caches the results of previous calls. If the same pattern is validated multiple times, the cached result is returned immediately, significantly improving the performance for repeated patterns. This change optimizes the runtime without altering the function's behavior.
2025-02-09 14:04:43 +00:00
fab
1a4a2d4e42
Merge pull request #9 from fabriziosalmi/codeflash/optimize-validate_regex-m6xkx22f
️ Speed up function `validate_regex` by 9,172%
2025-02-09 13:14:25 +01:00
codeflash-ai[bot]
a3104b23c1
️ Speed up function validate_regex by 9,172%
Changes made for optimization.
1. Added `functools.lru_cache` decorator to cache results of `validate_regex` function calls. This ensures that repeated validations of the same pattern are resolved quickly and avoid redundant regex compilations.
2025-02-09 12:07:05 +00:00
github-actions[bot]
1a98411808 Update: [Sun Feb 9 00:27:59 UTC 2025] 2025-02-09 00:27:59 +00:00
github-actions[bot]
7d2f1248c7 Update: [Sat Feb 8 00:25:04 UTC 2025] 2025-02-08 00:25:04 +00:00
github-actions[bot]
cf21042b9c Update: [Fri Feb 7 00:25:52 UTC 2025] 2025-02-07 00:25:52 +00:00
github-actions[bot]
1cebb95fc3 Update: [Thu Feb 6 00:25:50 UTC 2025] 2025-02-06 00:25:50 +00:00
github-actions[bot]
4f4fd8786e Update: [Wed Feb 5 00:25:42 UTC 2025] 2025-02-05 00:25:42 +00:00
github-actions[bot]
71e69a3a26 Update: [Tue Feb 4 00:25:09 UTC 2025] 2025-02-04 00:25:09 +00:00
fab
339a5e0350
Update test_apache_docker.yml 2025-02-03 02:05:58 +01:00
fab
c3578e4570
Update test_nginx.yml 2025-02-03 02:05:25 +01:00
fab
132380eeaf
Update update_patterns.yml 2025-02-03 02:04:42 +01:00
fab
437d3a251c
Update update_patterns.yml 2025-02-03 02:02:52 +01:00
github-actions[bot]
4e0dfb87e1 Update: [Mon Feb 3 00:26:12 UTC 2025] 2025-02-03 00:26:12 +00:00
github-actions[bot]
b3d0e38516 Update: [Sun Feb 2 00:27:06 UTC 2025] 2025-02-02 00:27:06 +00:00
github-actions[bot]
16e5ffb42c Update: [Sat Feb 1 00:27:37 UTC 2025] 2025-02-01 00:27:37 +00:00
github-actions[bot]
4f409f223d Update: [Fri Jan 31 00:25:27 UTC 2025] 2025-01-31 00:25:27 +00:00
github-actions[bot]
c0a6dd804a Update: [Thu Jan 30 00:24:54 UTC 2025] 2025-01-30 00:24:54 +00:00
github-actions[bot]
b242ea0619 Update: [Wed Jan 29 00:25:14 UTC 2025] 2025-01-29 00:25:14 +00:00
fabriziosalmi
f1bae07d6c feat: Generate Nginx WAF config with separate map and rule files
This commit modifies the script to output two files:
- waf_maps.conf (for http block)
- waf_rules.conf (for server block)
to avoid conflicts and provide more flexibility.

This update should fix the bugged nginx rules integration on existing setups: https://github.com/fabriziosalmi/patterns/issues/8
2025-01-28 22:41:54 +01:00
github-actions[bot]
eaf5714520 Update: [Tue Jan 28 00:25:35 UTC 2025] 2025-01-28 00:25:35 +00:00
github-actions[bot]
0e59b87df0 Update: [Mon Jan 27 00:26:20 UTC 2025] 2025-01-27 00:26:20 +00:00
github-actions[bot]
881bd34f0c Update: [Sun Jan 26 00:25:41 UTC 2025] 2025-01-26 00:25:41 +00:00
github-actions[bot]
fac08a29be Update: [Sat Jan 25 00:24:31 UTC 2025] 2025-01-25 00:24:31 +00:00
github-actions[bot]
1b5b529aaf Update: [Fri Jan 24 00:25:21 UTC 2025] 2025-01-24 00:25:21 +00:00
github-actions[bot]
a2a0049402 Update: [Thu Jan 23 00:25:20 UTC 2025] 2025-01-23 00:25:20 +00:00
github-actions[bot]
1abc68b227 Update: [Wed Jan 22 00:25:38 UTC 2025] 2025-01-22 00:25:38 +00:00
github-actions[bot]
5be5b718a6 Update: [Tue Jan 21 00:25:04 UTC 2025] 2025-01-21 00:25:04 +00:00
github-actions[bot]
1f2291133b Update: [Mon Jan 20 00:26:12 UTC 2025] 2025-01-20 00:26:12 +00:00
github-actions[bot]
57dc991ffc Update: [Sun Jan 19 00:27:39 UTC 2025] 2025-01-19 00:27:39 +00:00
github-actions[bot]
2bc6c53985 Update: [Sat Jan 18 00:24:13 UTC 2025] 2025-01-18 00:24:13 +00:00
fab
9ccac4241f
Update test_nginx.yml 2025-01-17 13:30:09 +01:00
fab
05571dad86
Update test_apache_docker.yml 2025-01-17 13:29:22 +01:00
fab
146335721c
Update and rename test_docker.yml to test_apache_docker.yml 2025-01-17 13:28:23 +01:00
fab
0d92cd36c6
Update test_docker.yml 2025-01-17 12:04:59 +01:00
fab
961d42a11f
Update test_docker.yml 2025-01-17 12:03:05 +01:00
fab
ddb39751e8
Update test_docker.yml
nginx & haproxy tests temp removed
2025-01-17 12:02:39 +01:00
fab
4eccf10943
Update test_docker.yml 2025-01-17 12:00:27 +01:00
github-actions[bot]
daeb6d2048 Update: [Fri Jan 17 00:25:08 UTC 2025] 2025-01-17 00:25:08 +00:00
fab
cf1a4da2bd
Rename nginx.yml to test_nginx.yml 2025-01-16 19:19:08 +01:00
fab
45d9f34241
Rename test.yml to test_docker.yml 2025-01-16 19:18:58 +01:00
fabriziosalmi
ae9c2756f7 test 2025-01-16 14:38:01 +01:00
fabriziosalmi
bc5eb455bf test 2025-01-16 14:33:59 +01:00
fabriziosalmi
3297168bec test 2025-01-16 14:31:04 +01:00
fabriziosalmi
64e14d23ef test 2025-01-16 14:28:30 +01:00
fabriziosalmi
84c4a49c2d action (crossplane) 2025-01-16 14:20:25 +01:00
fabriziosalmi
cc0a8de6c2 action 2025-01-16 14:19:16 +01:00