Commit graph

3420 commits

Author SHA1 Message Date
Sarthak Agarwal
43b15c68da
add secret scanner and monorepo hook (#1201)
### **User description**
### To Test this PR##
1. Clone and switch to the branch and Run `npm install`
2. Fork into a new branch to avoid pushing to this open PR
3. Add a file anywhere like test_secret.py and below code
```
def test_function():
    # This is a fake API key for testing purposes
    api_key = "12345-ABCDE-67890-FGHIJ"
    print("Testing secret detection.")
````
4. Add and try commiting the changes

### **User description**
closes #
https://linear.app/codeflash-ai/issue/CF-442/implement-a-secrets-scanning-solution-pre-commit-on-pr-deployments


___

### **PR Type**
enhancement, configuration changes


___

### **Description**
- Added Secretlint configuration to scan for secrets using recommended
rules.
- Introduced a shell script to run Ruff linting for Python projects.
- Updated README with setup instructions and prerequisites for Node.js,
npm, Python, and Mamba.
- Configured Lefthook for pre-commit hooks to perform secret scanning
and code linting.
- Created `package.json` with scripts for Lefthook installation and
Secretlint execution, and added relevant development dependencies.



___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Configuration
changes</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>secretlint.config.js</strong><dd><code>Add Secretlint
configuration with recommended rules</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

secretlint.config.js

<li>Added configuration for Secretlint.<br> <li> Included a rule preset
for recommended secret scanning.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1201/files#diff-134b2fd8c53958449a6b2a9f828d28149ffa192f0864afa76e82aa68a9c6cc20">+7/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>lefthook.yml</strong><dd><code>Configure Lefthook for
pre-commit secret and code linting</code></dd></summary>
<hr>

lefthook.yml

<li>Added Lefthook configuration for pre-commit hooks.<br> <li>
Configured secret scanning, Python linting, and JS linting commands.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1201/files#diff-ad6a01e589b8b1b214ca310dbb8d2e4314f6c612b921050c73c97455de43884d">+20/-0</a>&nbsp;
&nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>package.json</strong><dd><code>Add package.json with
scripts and dev dependencies</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

package.json

<li>Added project metadata and scripts for Lefthook and Secretlint.<br>
<li> Included development dependencies for Lefthook, Secretlint, and
<br>ESLint.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1201/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519">+23/-0</a>&nbsp;
&nbsp; </td>

</tr>                    
</table></td></tr><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>run_ruff.sh</strong><dd><code>Add shell script for Ruff
linting in Python projects</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

run_ruff.sh

<li>Added a shell script to run Ruff linting.<br> <li> Configured
environment activation and linting command.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1201/files#diff-08d9b9bfc882fa06fe0a67bf49f0512f2ea2202f99286e1d826bb94d6af5e333">+12/-0</a>&nbsp;
&nbsp; </td>

</tr>                    
</table></td></tr><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>README.md</strong><dd><code>Update README with project
setup and prerequisites</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

README.md

<li>Updated project setup instructions.<br> <li> Added prerequisites for
Node.js, npm, Python, and Mamba.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1201/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5">+8/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    
</table></td></tr></tr></tbody></table>

___

> 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull
request to receive relevant information


___

### **PR Type**
Enhancement, Configuration changes


___

### **Description**
- Added Secretlint configuration to scan for secrets using recommended
rules.
- Introduced a shell script to run Ruff linting for Python projects.
- Updated README with setup instructions and prerequisites for Node.js,
npm, Python, and Mamba.
- Configured Lefthook for pre-commit hooks to perform secret scanning
and code linting.
- Created `package.json` with scripts for Lefthook installation and
Secretlint execution, and added relevant development dependencies.



___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Configuration
changes</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>secretlint.config.js</strong><dd><code>Add Secretlint
configuration for secret scanning</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

secretlint.config.js

<li>Added Secretlint configuration file.<br> <li> Configured with
recommended rules for secret scanning.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1201/files#diff-134b2fd8c53958449a6b2a9f828d28149ffa192f0864afa76e82aa68a9c6cc20">+7/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>lefthook.yml</strong><dd><code>Configure Lefthook for
pre-commit secret scanning and linting</code></dd></summary>
<hr>

lefthook.yml

<li>Configured Lefthook for pre-commit hooks.<br> <li> Added commands
for secret scanning and code linting.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1201/files#diff-ad6a01e589b8b1b214ca310dbb8d2e4314f6c612b921050c73c97455de43884d">+20/-0</a>&nbsp;
&nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>package.json</strong><dd><code>Add package.json with
scripts and dependencies</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

package.json

<li>Created <code>package.json</code> for the monorepo.<br> <li> Added
scripts for Lefthook and Secretlint.<br> <li> Included development
dependencies.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1201/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519">+23/-0</a>&nbsp;
&nbsp; </td>

</tr>                    
</table></td></tr><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>run_ruff.sh</strong><dd><code>Introduce shell script
for Ruff linting in Python</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

run_ruff.sh

<li>Created a shell script to run Ruff linting.<br> <li> Script
navigates to the Python project directory.<br> <li> Activates Mamba
environment for linting.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1201/files#diff-08d9b9bfc882fa06fe0a67bf49f0512f2ea2202f99286e1d826bb94d6af5e333">+12/-0</a>&nbsp;
&nbsp; </td>

</tr>                    
</table></td></tr><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>README.md</strong><dd><code>Update README with setup
instructions and prerequisites</code>&nbsp; &nbsp; </dd></summary>
<hr>

README.md

<li>Added project setup instructions.<br> <li> Listed prerequisites for
Node.js, npm, Python, and Mamba.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1201/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5">+8/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    
</table></td></tr></tr></tbody></table>

___

> 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull
request to receive relevant information
2024-11-09 14:23:39 +00:00
Saurabh Misra
c46f254ec0
Merge pull request #1207 from codeflash-ai/webapp-build-fixes
some minor webapp build fixes
2024-11-07 23:26:14 -08:00
Saurabh Misra
5a7d0ad2e6 some minor webapp build fixes 2024-11-07 23:22:19 -08:00
Alvin Ryanputra
82639e513d
Merge pull request #1189 from codeflash-ai/range_limit_fix
Postprocessing pipeline, function to remove large loops (CF-439)
2024-11-07 17:36:24 -08:00
Alvin Ryanputra
50c8100520
Merge branch 'main' into range_limit_fix 2024-11-07 16:43:09 -08:00
Alvin Ryanputra
a0a70b0ac4 fixed some mistakes 2024-11-07 16:20:21 -08:00
Alvin Ryanputra
b5d19d901a rearranged pipeline order 2024-11-07 16:09:42 -08:00
Saurabh Misra
c83294b1cf
Merge pull request #1192 from codeflash-ai/webapp-ux-improvements
Make the Webapp UX easier
2024-11-07 14:56:44 -08:00
Saurabh Misra
7b78ab577c add reference to the docs as well 2024-11-06 22:25:15 -08:00
Saurabh Misra
339856166a updates 2024-11-06 22:19:18 -08:00
Alvin Ryanputra
dee3737019
Merge branch 'main' into range_limit_fix 2024-11-07 00:27:50 -05:00
Alvin Ryanputra
b13f8e47c8 Created a postprocess pipeline to modify testgen code. Implemented modify_large_loops function in the pipeline to manually convert large ranges above 1000 to range(1000), to prevent test execution taking too long 2024-11-06 21:24:01 -08:00
Sarthak Agarwal
0aade97af4
add exclude sensitive files from package build (#1190)
### **User description**
Adding files to be excluded while building pypi project or avoiding
sensitive files like .env from check in


___

### **PR Type**
enhancement, configuration changes


___

### **Description**
- Added exclusion rules in `pyproject.toml` files to prevent sensitive
and unnecessary files from being included in the package build.
- Excluded files include sensitive files like `.env` and `.pem`,
development files like `.git` and `Dockerfile`, and unnecessary file
types like `*.log` and `*.db`.
- This enhancement improves the security and cleanliness of the package
distribution.



___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Configuration
changes</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>pyproject.toml</strong><dd><code>Add exclusion rules
for sensitive and unnecessary files</code>&nbsp; &nbsp; </dd></summary>
<hr>

cli/pyproject.toml

<li>Added an <code>exclude</code> section to specify files and
directories to be <br>excluded from the package build.<br> <li> Included
patterns for sensitive files like <code>.env</code>, <code>.pem</code>,
and <code>secrets.*</code>.<br> <li> Excluded common development and
configuration files such as <code>.git</code>,
<br><code>Dockerfile</code>, and <code>.vscode</code>.<br> <li> Excluded
unnecessary file types like <code>*.log</code>, <code>*.tmp</code>, and
<code>*.db</code>.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1190/files#diff-0c21298b23605dcadf25950579e3ada906093fa49e7c5f98eaa7f3d816c29d28">+47/-0</a>&nbsp;
&nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>pyproject.toml</strong><dd><code>Add exclusion rules
for sensitive and unnecessary files</code>&nbsp; &nbsp; </dd></summary>
<hr>

django/aiservice/pyproject.toml

<li>Added an <code>exclude</code> section to specify files and
directories to be <br>excluded from the package build.<br> <li> Included
patterns for sensitive files like <code>.env</code>, <code>.pem</code>,
and <code>secrets.*</code>.<br> <li> Excluded common development and
configuration files such as <code>.git</code>,
<br><code>Dockerfile</code>, and <code>.vscode</code>.<br> <li> Excluded
unnecessary file types like <code>*.log</code>, <code>*.tmp</code>, and
<code>*.db</code>.<br>


</details>


  </td>
<td><a
href="https://github.com/codeflash-ai/codeflash/pull/1190/files#diff-1cd1f75beb8e70c006a688caffdd71f14a3babb13cc499ca48f499bd530fca1e">+45/-1</a>&nbsp;
&nbsp; </td>

</tr>                    
</table></td></tr></tr></tbody></table>

___

> 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull
request to receive relevant information
2024-11-06 20:44:55 +00:00
Alvin Ryanputra
1d5e05708e Created a postprocess pipeline to modify testgen code. Implemented modify_large_loops function in the pipeline to manually convert large ranges above 1000 to range(1000), to prevent test execution taking too long 2024-11-06 10:13:07 -08:00
Alvin Ryanputra
f3a41d6139
Merge pull request #1187 from codeflash-ai/testgen-parsing-issue
Added logs for generated test code before and after making modificati…
2024-11-04 20:04:55 -05:00
Alvin Ryanputra
12bef484c5 Removed break statement 2024-11-04 16:34:25 -08:00
Alvin Ryanputra
b08ed2ced7 Added logs for generated test code before and after making modifications so we can investigate Issue Cf-432.
Also added in erroring out after max retries has been exceeded for test generation
2024-11-04 16:28:36 -08:00
Saurabh Misra
e01b5d2656
Merge pull request #1173 from codeflash-ai/dependabot/pip/django/aiservice/uvicorn-tw-0.32.0
Update uvicorn requirement from ^0.30.0 to ^0.32.0 in /django/aiservice
2024-11-03 18:14:04 -08:00
Saurabh Misra
9aac6d216f
Merge branch 'main' into dependabot/pip/django/aiservice/uvicorn-tw-0.32.0 2024-11-03 17:47:23 -08:00
Saurabh Misra
829f2f19ee
Merge pull request #1185 from codeflash-ai/fix-yet-another-xml-parsing-crash
had this crash with pydantic
2024-11-02 12:37:25 -07:00
Saurabh Misra
8b10011909 had this crash with pydantic 2024-11-02 12:10:04 -07:00
Saurabh Misra
66d74e2bc8
Merge branch 'main' into dependabot/pip/django/aiservice/uvicorn-tw-0.32.0 2024-11-01 22:31:14 -07:00
Saurabh Misra
98cdfe4cf9
Merge pull request #1183 from codeflash-ai/release/v0.7.5
release/v0.7.5
2024-11-01 21:39:11 -07:00
Saurabh Misra
035614d8bf
Merge branch 'main' into release/v0.7.5 2024-11-01 18:24:24 -07:00
Saurabh Misra
1346388b70 release/v0.7.5 2024-11-01 18:24:04 -07:00
Saurabh Misra
3c7d2ee293
Merge pull request #1182 from codeflash-ai/make-e2e-bubblesort-more-permissive
reduce the min gain to 100% with e2e bubblesort
2024-11-01 18:22:05 -07:00
Saurabh Misra
8af0d20acc
Merge branch 'main' into make-e2e-bubblesort-more-permissive 2024-11-01 18:14:03 -07:00
Saurabh Misra
8f607755a3
Merge pull request #1164 from codeflash-ai/catch-one-more-exception-type
minor crash fix
2024-11-01 18:13:41 -07:00
Saurabh Misra
5f813e6536 reduce the min gain to 100% 2024-11-01 17:41:49 -07:00
Saurabh Misra
13cdbc522e
Merge pull request #1168 from codeflash-ai/tracer-fixes
Fix Tracer and Replay Tests
2024-11-01 17:11:30 -07:00
Saurabh Misra
6d66f17f80 revert to the previous code 2024-11-01 16:53:56 -07:00
Saurabh Misra
5c7f6cd4b9
Merge pull request #1170 from codeflash-ai/tracer-e2e-test
Add an end to end test for tracer
2024-11-01 16:50:18 -07:00
Saurabh Misra
17cce857c8 trace 3 function calls 2024-11-01 16:26:55 -07:00
Saurabh Misra
d1737bfe86 Merge branch 'refs/heads/tracer-fixes' into tracer-e2e-test 2024-11-01 16:25:26 -07:00
dependabot[bot]
4c587b457b
Update uvicorn requirement from ^0.30.0 to ^0.32.0 in /django/aiservice
Updates the requirements on [uvicorn](https://github.com/encode/uvicorn) to permit the latest version.
- [Release notes](https://github.com/encode/uvicorn/releases)
- [Changelog](https://github.com/encode/uvicorn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/encode/uvicorn/compare/0.30.0...0.32.0)

---
updated-dependencies:
- dependency-name: uvicorn
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-01 13:34:25 +00:00
Saurabh Misra
8db220e430 github action workflow 2024-10-31 20:00:48 -07:00
Saurabh Misra
d76f77bae8 Add an end to end test for tracer 2024-10-31 19:57:48 -07:00
Saurabh Misra
af5c6d29d0 Fix replay testing execution 2024-10-31 19:48:57 -07:00
Saurabh Misra
a3d061faf4 Fix replay testing 2024-10-31 15:37:31 -07:00
Saurabh Misra
8006ac51c0 Merge remote-tracking branch 'origin/tracer-fixes' into tracer-fixes 2024-10-31 12:04:04 -07:00
Saurabh Misra
1d6a588bcf fix a tracer path bug 2024-10-31 12:03:50 -07:00
Saurabh Misra
0f1c0d57f1
Merge pull request #1169 from codeflash-ai/codeflash/optimize-TestResults.get_by_id-2024-10-31T04.52.39
️ Speed up method `TestResults.get_by_id` by 28% in `cli/codeflash/verification/test_results.py`
2024-10-30 22:05:25 -07:00
codeflash-ai[bot]
6c16c6d617
️ Speed up method TestResults.get_by_id by 28%
To optimize the provided Python code for runtime and memory efficiency, various changes can be made, such as avoiding repeated computations, using more efficient data structures, and reducing unnecessary calls. Here is the optimized version of the program.



Here are the key optimizations made.

1. Inline variable calculation: Removed unnecessary recomputation of the test class and function string during the `id()` method.
2. Simplified `from_str_id`: Used more concise splitting and assignment for `test_class_name` and `test_function_name`.
3. Cached `other` test results in `__eq__` method using a dictionary for faster lookup.
4. Streamlined `get_by_id` method by switching to a direct loop instead of using a generator expression with `next()`.
5. Added `test_results` attribute declaration in `TestResults` dataclass to avoid potential `AttributeError`.

These adjustments help in reducing overhead, unnecessary computations, and improving the clarity of the code, ultimately making the program execute faster.
2024-10-31 04:52:42 +00:00
Saurabh Misra
d2afc0a66c Fix Tracer pathlib issues 2024-10-30 21:45:59 -07:00
Saurabh Misra
3963c3633c
Merge pull request #1166 from codeflash-ai/progress-bars-for-optimization-candidates
add progress bar for optimization candidate run as well
2024-10-30 21:28:30 -07:00
Saurabh Misra
84bdccdec7 add progress bar for optimization candidate run as well 2024-10-30 20:53:31 -07:00
Saurabh Misra
82238ec641 fix testname parsing crash 2024-10-30 18:14:01 -07:00
Saurabh Misra
3876999300 log one more failure, make the exception more general 2024-10-30 16:03:24 -07:00
Saurabh Misra
d10d700ac8 minor crash fix 2024-10-30 13:53:35 -07:00
Saurabh Misra
20323b4755
Merge pull request #1162 from codeflash-ai/better-debug-logging-for-crash-here
better logging for future to debug whats wrong
2024-10-29 22:00:37 -07:00