Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tasks": {
"test": "pytest",
"build": "pip install -r requirements.txt && bash setup.sh",
"launch": "pip install -r requirements.txt && python app.py"
}
}
19 changes: 2 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
# Use a slim Python base image
FROM python:3.9-slim

# Set the working directory
WORKDIR /app

# Create a non-root user and switch to it
RUN useradd -m appuser
USER appuser

# Copy project files
COPY . /app

# Install dependencies
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

# Expose the Gradio default port
EXPOSE 7860

# Set environment variables for API keys
ENV OPENAI_API_KEY=${OPENAI_API_KEY}
ENV HUGGINGFACE_API_KEY=${HUGGINGFACE_API_KEY}

# Command to start the Gradio app
CMD ["python", "src/frontend/archive_gui.py"]
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"]
132 changes: 132 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,3 +507,135 @@ print(f"Blockchain integrity: {is_valid}")
- **SIEM**: Integrated security information and event management capabilities.
- **Container Security**: Added modules for securing containerized environments.
- **Serverless Security**: Integrated serverless security capabilities.

### Secure Password Storage

To ensure secure password storage, the `models.py` file has been updated to use `bcrypt` for password hashing. This ensures that passwords are stored securely and are resistant to common attacks such as brute-force and rainbow table attacks.

### Input Validation

Input validation has been implemented in the `app.py` file to ensure that user input is valid and secure. This helps prevent common security vulnerabilities such as SQL injection and cross-site scripting (XSS).

### Rate Limiting

Rate limiting has been implemented in the `app.py` file to prevent brute-force attacks and denial-of-service (DoS) attacks. This ensures that the application can handle a large number of requests without being overwhelmed.

### Secure Communication

The `app.py` file has been updated to use a secure communication protocol like HTTPS or TLS to protect data in transit. This ensures that sensitive data is encrypted and cannot be intercepted by attackers.

### Security Headers

Security headers have been added to the `app.py` file to protect against common web vulnerabilities such as XSS and clickjacking. This helps ensure that the application is secure and resistant to common attacks.

### Example Usage of Secure Password Storage

```python
# Example of using bcrypt for secure password storage
from flask_bcrypt import Bcrypt

bcrypt = Bcrypt()

# Hash a password
password = "my_secure_password"
hashed_password = bcrypt.generate_password_hash(password).decode('utf-8')
print(f"Hashed password: {hashed_password}")

# Verify a password
is_valid = bcrypt.check_password_hash(hashed_password, password)
print(f"Password is valid: {is_valid}")
```

### Example Usage of Input Validation

```python
# Example of input validation in Flask
from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/login', methods=['POST'])
def login():
username = request.form.get('username')
password = request.form.get('password')

# Validate input data
if not username or not password:
return jsonify({'error': 'Invalid input data'}), 400

# Perform login logic
# ...

return jsonify({'message': 'Login successful'}), 200

if __name__ == '__main__':
app.run(debug=True)
```

### Example Usage of Rate Limiting

```python
# Example of rate limiting in Flask
from flask import Flask, request, jsonify
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address

app = Flask(__name__)
limiter = Limiter(
get_remote_address,
app=app,
default_limits=["200 per day", "50 per hour"]
)

@app.route('/login', methods=['POST'])
@limiter.limit("10 per minute")
def login():
username = request.form.get('username')
password = request.form.get('password')

# Validate input data
if not username or not password:
return jsonify({'error': 'Invalid input data'}), 400

# Perform login logic
# ...

return jsonify({'message': 'Login successful'}), 200

if __name__ == '__main__':
app.run(debug=True)
```

### Example Usage of Secure Communication

```python
# Example of using HTTPS in Flask
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
return "Welcome to Project Red Sword"

if __name__ == '__main__':
app.run(debug=True, ssl_context='adhoc')
```

### Example Usage of Security Headers

```python
# Example of adding security headers in Flask
from flask import Flask
from flask_talisman import Talisman

app = Flask(__name__)
talisman = Talisman(app)

@app.route('/')
def index():
return "Welcome to Project Red Sword"

if __name__ == '__main__':
app.run(debug=True)
```
Loading
Loading