Skip to content

Demo Quality Kit #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Demo Quality Kit #170

wants to merge 1 commit into from

Conversation

vlussenburg
Copy link
Collaborator

@vlussenburg vlussenburg commented Jun 7, 2025

✨ PR Description

This PR enhances the e-commerce application with improved functionality and user experience.

Main changes:

  • Added order history feature to frontend and backend
  • Implemented in-memory database for order storage in Java service
  • Enhanced UI with styled components and dropdown for product selection

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

Copy link

gitstream-cm bot commented Jun 7, 2025

This PR affects one or more sensitive files and requires review from the security team.

Copy link

gitstream-cm bot commented Jun 7, 2025

🥷 Code experts: amitmohleji, b-sims

amitmohleji, b-sims have most 👩‍💻 activity in the files.
b-sims, amitmohleji have most 🧠 knowledge in the files.

See details

frontend/package.json

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR 8 additions & 0 deletions
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/app.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR 33 additions & 0 deletions
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/index.html

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR 20 additions & 0 deletions
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/server.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR 37 additions & 0 deletions
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

services/auth-python/app/auth.py

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/billing-csharp/Controllers/BillingController.cs

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/orders-java/pom.xml

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 54 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/main/java/com/example/orders/controller/OrderController.java

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 75 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/test/java/com/example/orders/OrdersApplicationTests.java

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 86 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

To learn more about /:\ gitStream - Visit our Docs

@gitstream-cm gitstream-cm bot requested review from amitmohleji and b-sims June 7, 2025 03:31
Copy link

@gitstream-cm gitstream-cm bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ PR Review

The PR adds comprehensive order management functionality with database persistence, order history, and improved UI. However, there are significant security vulnerabilities and race conditions that need addressing.

3 issues detected:

🔒 Security - Concurrent file access without synchronization can lead to lost billing records and data corruption.

Details: The QueueForBillingSystemAsync method has a race condition where concurrent requests can cause data corruption. Multiple threads can read the same file simultaneously, modify their own copy, and overwrite each other's changes when writing back to the file.
File: services/billing-csharp/Controllers/BillingController.cs (56-72)

🔒 Security - Direct string concatenation in URL construction with user input can lead to URL manipulation vulnerabilities.

Details: The validateToken method uses string concatenation to build URLs with user input, which could potentially allow URL manipulation attacks. Additionally, the token parameter is directly concatenated into the URL without proper encoding.
File: services/orders-java/src/main/java/com/example/orders/controller/OrderController.java (121-121)

🔒 Security - Stack traces printed to console can expose sensitive system information and internal application structure.

Details: Exception stack traces are printed to console in multiple locations, potentially exposing sensitive system information in logs. This can aid attackers in understanding the system architecture and finding vulnerabilities.
File: services/orders-java/src/main/java/com/example/orders/controller/OrderController.java (75-75)

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

Comment on lines +56 to +72
private async Task QueueForBillingSystemAsync(string username, object payload)
{
Directory.CreateDirectory(StorageDirectory);
var filePath = Path.Combine(StorageDirectory, $"{username}.json");
List<object> payloads = new();

if (System.IO.File.Exists(filePath))
{
try
{
payloads = JsonSerializer.Deserialize<List<object>>(await System.IO.File.ReadAllTextAsync(filePath)) ?? new();
}
catch { }
}

payloads.Add(payload);
await System.IO.File.WriteAllTextAsync(filePath, JsonSerializer.Serialize(payloads, new JsonSerializerOptions { WriteIndented = true }));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security - Race Condition: Implement proper file locking using FileStream with FileShare.None or use a thread-safe collection with proper synchronization mechanisms like SemaphoreSlim around the file operations.

Suggested change
private async Task QueueForBillingSystemAsync(string username, object payload)
{
Directory.CreateDirectory(StorageDirectory);
var filePath = Path.Combine(StorageDirectory, $"{username}.json");
List<object> payloads = new();
if (System.IO.File.Exists(filePath))
{
try
{
payloads = JsonSerializer.Deserialize<List<object>>(await System.IO.File.ReadAllTextAsync(filePath)) ?? new();
}
catch { }
}
payloads.Add(payload);
await System.IO.File.WriteAllTextAsync(filePath, JsonSerializer.Serialize(payloads, new JsonSerializerOptions { WriteIndented = true }));
private static readonly SemaphoreSlim _fileLock = new SemaphoreSlim(1, 1);
private async Task QueueForBillingSystemAsync(string username, object payload)
{
Directory.CreateDirectory(StorageDirectory);
var filePath = Path.Combine(StorageDirectory, $"{username}.json");
await _fileLock.WaitAsync();
try
{
List<object> payloads = new();
if (System.IO.File.Exists(filePath))
{
try
{
payloads = JsonSerializer.Deserialize<List<object>>(await System.IO.File.ReadAllTextAsync(filePath)) ?? new();
}
catch { }
}
payloads.Add(payload);
await System.IO.File.WriteAllTextAsync(filePath, JsonSerializer.Serialize(payloads, new JsonSerializerOptions { WriteIndented = true }));
}
finally
{
_fileLock.Release();
}


return ResponseEntity.ok(response.toString());
}

protected String validateToken(String token) {
String authUrl = authServiceUrl + "/auth/validate?token=" + token;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security - SQL Injection: Use proper URL encoding for the token parameter and consider using UriComponentsBuilder or similar utilities to safely construct URLs with query parameters.

Suggested change
String authUrl = authServiceUrl + "/auth/validate?token=" + token;
String authUrl = authServiceUrl + "/auth/validate?token=" + java.net.URLEncoder.encode(token, java.nio.charset.StandardCharsets.UTF_8);

pstmt.setString(5, timestamp);
pstmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security - Information Disclosure: Replace printStackTrace() calls with proper logging that sanitizes sensitive information and logs at appropriate levels. Use a logging framework like SLF4J with structured error messages.

Suggested change
e.printStackTrace();
logger.error("Failed to store order for user: {}", username, e);

Copy link

gitstream-cm bot commented Jun 7, 2025

This PR is missing a Jira ticket reference in the title or description.
Please add a Jira ticket reference to the title or description of this PR.

Copy link

gitstream-cm bot commented Jun 7, 2025

Hello vlussenburg 👋 Thanks for making your first PR, and welcome to our project!
Our mentor team has automatically been assigned to review this PR and guide you through the process.
Please reach out to that team if you have questions about the next steps.

Copy link

gitstream-cm bot commented Jun 7, 2025

🥷 Code experts: amitmohleji, b-sims

amitmohleji, b-sims have most 👩‍💻 activity in the files.
b-sims, amitmohleji have most 🧠 knowledge in the files.

See details

frontend/package.json

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR 8 additions & 0 deletions
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/app.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR 33 additions & 0 deletions
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/index.html

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR 20 additions & 0 deletions
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/server.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR 37 additions & 0 deletions
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

services/auth-python/app/auth.py

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/billing-csharp/Controllers/BillingController.cs

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/orders-java/pom.xml

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 54 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/main/java/com/example/orders/controller/OrderController.java

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 75 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/test/java/com/example/orders/OrdersApplicationTests.java

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 86 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

To learn more about /:\ gitStream - Visit our Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant