diff --git a/example-outputs/agentic-full.md b/example-outputs/agentic-full.md index e69de29..0f41ad9 100644 --- a/example-outputs/agentic-full.md +++ b/example-outputs/agentic-full.md @@ -0,0 +1,36 @@ +Here's a summary of the security issues found: + +1. **Environment Variables Exposure**: + - **File**: `./src/latio/core.py` + - **Lines**: 27, 28 + - **Issue**: API keys are accessed directly from environment variables without additional security measures. + - **Fix**: Use a secure configuration management tool like `python-decouple` or `dotenv` to manage sensitive data. For example, load keys with `config('API_KEY', default='')`. + +2. **Subprocess Use**: + - **File**: `./src/latio/core.py` + - **Lines**: 40, 119, 132 + - **Issue**: Direct use of `subprocess` can lead to command injection if inputs are not validated. + - **Fix**: Use the `subprocess.run()` method with `shell=False` and input validation. For example: + ```python + subprocess.run(["git", "diff", "--name-status", base_ref, head_ref], check=True, text=True) + ``` + +3. **Error Handling**: + - **Files**: `./src/latio/core.py`, `./src/latio/workers.py` + - **Lines**: Multiple instances + - **Issue**: Numerous try-except blocks lack specific error handling, which may hide issues. + - **Fix**: Implement specific exception handling and logging. Use logging libraries to capture errors rather than print statements. + +4. **Open Files Without Validation**: + - **File**: `./src/latio/workers.py` + - **Lines**: 27, 74, 149, 173 + - **Issue**: Files are opened without validating the existence or type, which might result in unexpected behavior. + - **Fix**: Validate or sanitize inputs and handle errors appropriately. Use `os.path.exists()` before opening files. + +5. **Git Command Execution**: + - **File**: `./src/latio/core.py` + - **Lines**: 61, 178 + - **Issue**: Running git commands using `subprocess` without validation of input can be insecure. + - **Fix**: Ensure paths and inputs are validated and sanitized before executing git commands. Use safer methods of interfacing with Git, such as using GitPython. + +These fixes will help enhance the security of the application. Let me know if you need further assistance! \ No newline at end of file diff --git a/example-outputs/non-agentic-full.md b/example-outputs/non-agentic-full.md index e69de29..a9f2bc0 100644 --- a/example-outputs/non-agentic-full.md +++ b/example-outputs/non-agentic-full.md @@ -0,0 +1,35 @@ +The code provided for review consists of multiple files with various functions related to analyzing and scanning code for security and health issues using OpenAI and Google Gemini APIs. Here are some potential security vulnerabilities and issues that should be addressed: + +1. **Hardcoded Credentials**: + - There might be a risk of exposing API keys if they are hardcoded or improperly managed. Ensure that `OPENAI_API_KEY`, `GITHUB_TOKEN`, and `GEMINI_API_KEY` are securely managed and not hardcoded in the source code. Use environment variables or a secure vault. + +2. **Command Injection**: + - Functions like `get_changed_files`, `get_line_changes`, and `get_changed_files_github` use `subprocess.check_output` to execute Git commands. Ensure that any inputs to these commands are properly sanitized to prevent command injection attacks. + +3. **File Handling**: + - When reading files (especially in `analyze_code_context` and `gather_full_code` functions), ensure that the file paths are validated and sanitized to prevent directory traversal attacks. + - Use context managers (`with` statements) for file operations to ensure files are properly closed after operations. + +4. **Error Handling**: + - There are several places where exceptions are caught broadly using `except Exception as e`. This can mask other issues and make debugging difficult. Consider catching specific exceptions and handling them appropriately. + - In functions like `get_line_changes`, ensure that all potential exceptions are logged or handled to prevent silent failures. + +5. **Injection Risks in AI Models**: + - When sending data to AI models (e.g., in `full_sec_scan`, `partial_sec_scan`), ensure that the data is properly sanitized and does not include sensitive information. AI models can inadvertently leak information if prompts are not correctly managed. + +6. **Logging Sensitive Information**: + - Avoid logging sensitive information such as file contents or API responses unless absolutely necessary. Ensure that logs are properly secured and access-controlled. + +7. **Concurrency Issues**: + - Functions that use `asyncio` should be properly managed to prevent concurrency issues. Ensure that any shared resources are protected against race conditions. + +8. **Use of External Libraries**: + - Ensure that all external libraries and dependencies are up to date with the latest security patches. Regularly audit dependencies for known vulnerabilities using tools like `pip-audit`. + +9. **Security Headers and Best Practices**: + - When making HTTP requests (e.g., using `requests.get`), consider using security headers like `User-Agent` and ensure SSL/TLS verification is enforced. + +10. **Data Exposure**: + - Be cautious about exposing detailed application data in AI prompts or external requests. Use redaction or summarization where possible to minimize information leakage. + +By addressing the above issues, you can enhance the security posture of the application. Additionally, consider conducting regular security reviews and penetration testing to identify further vulnerabilities. \ No newline at end of file diff --git a/setup.py b/setup.py index ec3b4cc..2386f86 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='latio', - version='v1.2.2', + version='v1.2.3', url='https://github.com/latiotech/LAST', license='GPL-3.0 license', author='James Berthoty', @@ -19,5 +19,20 @@ 'console_scripts': ['latio = latio.core:main'], }, long_description=long_description, - long_description_content_type='text/markdown' + long_description_content_type='text/markdown', + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Security', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + ], + python_requires='>=3.8', + package_dir={'': 'src'}, + packages=['latio'], + include_package_data=True, ) diff --git a/src/latio/core.py b/src/latio/core.py index 5e0733a..83de904 100644 --- a/src/latio/core.py +++ b/src/latio/core.py @@ -13,7 +13,10 @@ from IPython.display import display from IPython.display import Markdown import asyncio -import workers +try: + from . import workers +except ImportError: + import workers def to_markdown(text): text = text.replace('•', ' *')