Skip to content

Commit f2c0de8

Browse files
Fix security vulnerabilities and remove console statements
Co-authored-by: jemartinezrdz <[email protected]>
1 parent 04ba0d6 commit f2c0de8

File tree

8 files changed

+203
-11
lines changed

8 files changed

+203
-11
lines changed

SECURITY.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
We currently support the following versions of AutoDocOps with security updates:
6+
7+
| Version | Supported |
8+
| ------- | ------------------ |
9+
| 1.x.x | :white_check_mark: |
10+
| < 1.0 | :x: |
11+
12+
## Reporting a Vulnerability
13+
14+
We take the security of AutoDocOps seriously. If you believe you have found a security vulnerability, please report it to us as described below.
15+
16+
### Where to Report
17+
18+
Please report security vulnerabilities by email to: **[email protected]**
19+
20+
**Please do not report security vulnerabilities through public GitHub issues.**
21+
22+
### What to Include
23+
24+
Please include as much of the following information as possible:
25+
26+
- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
27+
- Full paths of source file(s) related to the manifestation of the issue
28+
- The location of the affected source code (tag/branch/commit or direct URL)
29+
- Any special configuration required to reproduce the issue
30+
- Step-by-step instructions to reproduce the issue
31+
- Proof-of-concept or exploit code (if possible)
32+
- Impact of the issue, including how an attacker might exploit the issue
33+
34+
### Response Timeline
35+
36+
- **Initial Response**: We will acknowledge receipt of your vulnerability report within 48 hours.
37+
- **Status Updates**: We will provide status updates every 7 days until the issue is resolved.
38+
- **Resolution**: We will fix the vulnerability within 30 days for critical issues, 60 days for high severity issues.
39+
40+
### Disclosure Policy
41+
42+
- We will coordinate disclosure of the vulnerability with you.
43+
- We will not disclose the vulnerability until a fix is available.
44+
- We will credit you for the discovery if you wish.
45+
46+
## Security Measures
47+
48+
### Code Security
49+
50+
- All code is reviewed before merging
51+
- Automated security scanning with CodeQL, OWASP Dependency Check, and Trivy
52+
- Regular dependency updates to address known vulnerabilities
53+
- Input validation and sanitization for all user inputs
54+
55+
### Infrastructure Security
56+
57+
- All API endpoints require authentication
58+
- JWT tokens with proper expiration
59+
- HTTPS-only communication in production
60+
- Rate limiting to prevent abuse
61+
- Database connection strings are encrypted
62+
63+
### Data Protection
64+
65+
- Sensitive configuration data is stored in environment variables
66+
- No hardcoded secrets in source code
67+
- Proper access controls on all data repositories
68+
- Regular security audits
69+
70+
## Security Best Practices for Users
71+
72+
### API Keys and Secrets
73+
74+
1. **Never commit API keys or secrets to version control**
75+
2. **Use environment variables for all sensitive configuration**
76+
3. **Rotate API keys regularly**
77+
4. **Use least-privilege access principles**
78+
79+
### Deployment
80+
81+
1. **Use HTTPS in production**
82+
2. **Keep dependencies updated**
83+
3. **Enable security headers**
84+
4. **Regular security monitoring**
85+
86+
### Configuration
87+
88+
1. **Change default passwords and secrets**
89+
2. **Enable logging and monitoring**
90+
3. **Use strong JWT secrets**
91+
4. **Configure proper CORS settings**
92+
93+
## Acknowledgments
94+
95+
We appreciate the security research community and will acknowledge researchers who responsibly disclose vulnerabilities to us.
96+
97+
## Contact
98+
99+
For any security-related questions or concerns, please contact us at:
100+
101+
- For general questions: [email protected]
102+
103+
---
104+
105+
This security policy is effective as of December 2024 and will be reviewed and updated regularly.

backend/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@ RUN dotnet publish -c Release -o /app/publish
1717

1818
# Runtime stage
1919
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
20+
21+
# Create a non-root user
22+
RUN groupadd -r appuser && useradd -r -g appuser appuser
23+
2024
WORKDIR /app
2125
COPY --from=publish /app/publish .
2226

27+
# Change ownership of the app directory to the non-root user
28+
RUN chown -R appuser:appuser /app
29+
30+
# Switch to non-root user
31+
USER appuser
32+
2333
# Expose port
2434
EXPOSE 8080
2535
ENV ASPNETCORE_URLS=http://0.0.0.0:8080

backend/ENVIRONMENT_VARIABLES.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Environment Variables Configuration
2+
3+
## Required Environment Variables
4+
5+
The following environment variables must be configured for the application to work properly:
6+
7+
### JWT Configuration
8+
- `JWT_KEY`: Secret key for JWT token generation (minimum 32 characters)
9+
- `JWT_ISSUER`: JWT token issuer (default: "AutoDocOps")
10+
- `JWT_AUDIENCE`: JWT token audience (default: "AutoDocOps-Users")
11+
- `JWT_EXPIRY_HOURS`: JWT token expiry in hours (default: 24)
12+
13+
### Database Configuration
14+
- `CONNECTION_STRINGS__DEFAULTCONNECTION`: Database connection string
15+
- `SUPABASE__URL`: Supabase project URL
16+
- `SUPABASE__KEY`: Supabase anon key
17+
- `SUPABASE__SERVICEKEY`: Supabase service role key
18+
- `SUPABASE__JWTSECRET`: Supabase JWT secret
19+
20+
### OpenAI Configuration
21+
- `OPENAI__APIKEY`: OpenAI API key
22+
- `OPENAI__MODEL`: OpenAI model to use (default: "gpt-4o-mini")
23+
- `OPENAI__EMBEDDINGMODEL`: OpenAI embedding model (default: "text-embedding-3-small")
24+
- `OPENAI__MAXTOKENS`: Maximum tokens for OpenAI requests (default: 4000)
25+
- `OPENAI__TEMPERATURE`: Temperature for OpenAI requests (default: 0.1)
26+
27+
### CORS Configuration
28+
- `CORS__ALLOWEDORIGINS__0`: First allowed origin
29+
- `CORS__ALLOWEDORIGINS__1`: Second allowed origin (add more as needed)
30+
31+
## Example .env file
32+
33+
Create a `.env` file in the backend root directory:
34+
35+
```env
36+
# JWT Configuration
37+
JWT_KEY=your-super-secret-jwt-key-with-at-least-32-characters
38+
JWT_ISSUER=AutoDocOps
39+
JWT_AUDIENCE=AutoDocOps-Users
40+
JWT_EXPIRY_HOURS=24
41+
42+
# Database Configuration
43+
CONNECTION_STRINGS__DEFAULTCONNECTION=Host=localhost;Database=autodocops;Username=postgres;Password=your-password
44+
45+
# Supabase Configuration
46+
SUPABASE__URL=https://your-project.supabase.co
47+
SUPABASE__KEY=your-anon-key
48+
SUPABASE__SERVICEKEY=your-service-role-key
49+
SUPABASE__JWTSECRET=your-jwt-secret
50+
51+
# OpenAI Configuration
52+
OPENAI__APIKEY=your-openai-api-key
53+
OPENAI__MODEL=gpt-4o-mini
54+
OPENAI__EMBEDDINGMODEL=text-embedding-3-small
55+
OPENAI__MAXTOKENS=4000
56+
OPENAI__TEMPERATURE=0.1
57+
58+
# CORS Configuration
59+
CORS__ALLOWEDORIGINS__0=http://localhost:8081
60+
CORS__ALLOWEDORIGINS__1=https://your-frontend-domain.com
61+
```
62+
63+
## Docker Configuration
64+
65+
For Docker deployments, these environment variables can be passed using:
66+
67+
1. Docker Compose `.env` file
68+
2. Docker run `-e` parameters
69+
3. Kubernetes ConfigMaps and Secrets
70+
71+
## Security Notes
72+
73+
- Never commit the `.env` file to version control
74+
- Use strong, randomly generated keys for JWT secrets
75+
- Rotate secrets regularly
76+
- Use different secrets for different environments
77+
- Store production secrets in secure key management systems (Azure Key Vault, AWS Secrets Manager, etc.)

backend/src/AutoDocOps.Api/AutoDocOps.Api/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"DefaultConnection": "Host=localhost;Database=autodocops_dev;Username=postgres;Password=dev_password"
1111
},
1212
"Jwt": {
13-
"Key": "AutoDocOps-Development-Secret-Key-For-JWT-Token-Generation-2024",
13+
"Key": "",
1414
"ExpiryInHours": 168
1515
},
1616
"Features": {

backend/src/AutoDocOps.Api/AutoDocOps.Api/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"DefaultConnection": "Host=localhost;Database=autodocops;Username=postgres;Password=password"
1212
},
1313
"Jwt": {
14-
"Key": "AutoDocOps-Super-Secret-Key-For-JWT-Token-Generation-2024",
14+
"Key": "",
1515
"Issuer": "AutoDocOps",
1616
"Audience": "AutoDocOps-Users",
1717
"ExpiryInHours": 24

backend/src/AutoDocOps.Infrastructure/AutoDocOps.Infrastructure/Services/OpenAIService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,10 @@ private async Task<string> CallOpenAIAsync(string prompt)
358358
var json = JsonSerializer.Serialize(requestBody);
359359
var content = new StringContent(json, Encoding.UTF8, "application/json");
360360

361-
var response = await _httpClient.PostAsync("https://api.openai.com/v1/chat/completions", content);
361+
var response = await _httpClient.PostAsync("https://api.openai.com/v1/chat/completions", content).ConfigureAwait(false);
362362
response.EnsureSuccessStatusCode();
363363

364-
var responseJson = await response.Content.ReadAsStringAsync();
364+
var responseJson = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
365365
var responseObj = JsonSerializer.Deserialize<JsonElement>(responseJson);
366366

367367
return responseObj

frontend/AutoDocOps-Frontend/src/contexts/AuthContext.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
117117
dispatch({ type: 'SET_LOADING', payload: false });
118118
}
119119
} catch (error) {
120-
console.error('Error restoring session:', error);
120+
// Error restoring session - user will need to login again
121121
dispatch({ type: 'SET_LOADING', payload: false });
122122
}
123123
};
@@ -179,7 +179,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
179179
// Call logout endpoint
180180
await apiService.post('/auth/logout');
181181
} catch (error) {
182-
console.error('Error calling logout endpoint:', error);
182+
// Error calling logout endpoint - will clear session anyway
183183
} finally {
184184
await clearStoredSession();
185185
dispatch({ type: 'LOGOUT' });
@@ -202,7 +202,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
202202
await SecureStore.setItemAsync(STORAGE_KEYS.AUTH_TOKEN, token);
203203
}
204204
} catch (error) {
205-
console.error('Error refreshing token:', error);
205+
// Error refreshing token - logout user
206206
await logout();
207207
}
208208
};
@@ -213,7 +213,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
213213
await SecureStore.deleteItemAsync(STORAGE_KEYS.USER_DATA);
214214
await apiService.clearAuthToken();
215215
} catch (error) {
216-
console.error('Error clearing stored session:', error);
216+
// Error clearing stored session - operation failed silently
217217
}
218218
};
219219

frontend/AutoDocOps-Frontend/src/services/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ApiService {
6161
this.authToken = token;
6262
}
6363
} catch (error) {
64-
console.error('Error loading auth token:', error);
64+
// Error loading auth token - token will remain null
6565
}
6666
}
6767

@@ -70,7 +70,7 @@ class ApiService {
7070
this.authToken = token;
7171
await SecureStore.setItemAsync(STORAGE_KEYS.AUTH_TOKEN, token);
7272
} catch (error) {
73-
console.error('Error saving auth token:', error);
73+
// Error saving auth token - operation failed silently
7474
}
7575
}
7676

@@ -79,7 +79,7 @@ class ApiService {
7979
this.authToken = null;
8080
await SecureStore.deleteItemAsync(STORAGE_KEYS.AUTH_TOKEN);
8181
} catch (error) {
82-
console.error('Error clearing auth token:', error);
82+
// Error clearing auth token - operation failed silently
8383
}
8484
}
8585

0 commit comments

Comments
 (0)