Skip to content

Demo Quality Kit #258

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 #258

wants to merge 1 commit into from

Conversation

vlussenburg
Copy link
Collaborator

@vlussenburg vlussenburg commented Jun 29, 2025

✨ PR Description

Purpose: Adds order history functionality and Swagger documentation to the e-commerce microservices architecture.

Main changes:

  • Implemented GET /api/orders/history endpoint with UI integration for viewing order history.
  • Added Swagger UI documentation for frontend API endpoints using swagger-jsdoc and swagger-ui-express.
  • Enhanced OrderController in Java to store orders in H2 database and implemented order retrieval.

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 29, 2025

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

Copy link

gitstream-cm bot commented Jun 29, 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 8 additions & 0 deletions
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/app.js

Activity based on git-commit:

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

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/index.html

Activity based on git-commit:

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

Knowledge based on git-blame:
amitmohleji: 100%

frontend/server.js

Activity based on git-commit:

amitmohleji b-sims
JUN 37 additions & 0 deletions
MAY
APR
MAR
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
APR 54 additions & 0 deletions
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
APR 75 additions & 0 deletions
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
APR 86 additions & 0 deletions
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 29, 2025 03:39
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 database persistence, order history functionality, and improved UI/documentation. The implementation includes proper database initialization and error handling, but has a critical security vulnerability in the billing service and some maintainability concerns.

3 issues detected:

🔒 Security - User input is directly concatenated into file paths without sanitization

Details: The file path construction uses username directly without validation, allowing potential directory traversal attacks. A malicious username like "../../../etc/passwd" could access or overwrite system files.
File: services/billing-csharp/Controllers/BillingController.cs (59-59)

🐞 Bug - Non-atomic file operations can cause data loss under concurrent access

Details: The file read-modify-write operation is not atomic, which can lead to data corruption if multiple concurrent requests attempt to update the same user's billing file simultaneously.
File: services/billing-csharp/Controllers/BillingController.cs (62-72)

🧹 Maintainability - Generic exception handling reduces debuggability and may expose sensitive information

Details: Database exceptions are caught with a generic catch block and only printed to console, making debugging difficult and potentially exposing sensitive information through stack traces.
File: services/orders-java/src/main/java/com/example/orders/controller/OrderController.java (74-75)

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

private async Task QueueForBillingSystemAsync(string username, object payload)
{
Directory.CreateDirectory(StorageDirectory);
var filePath = Path.Combine(StorageDirectory, $"{username}.json");
Copy link

Choose a reason for hiding this comment

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

🔒 Security - Path Traversal Vulnerability: Sanitize the username parameter by removing or escaping special characters, or use a whitelist approach to validate usernames before constructing file paths.

Suggested change
var filePath = Path.Combine(StorageDirectory, $"{username}.json");
var sanitizedUsername = SanitizeUsername(username);
var filePath = Path.Combine(StorageDirectory, $"{sanitizedUsername}.json");

Comment on lines +62 to +72
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.

🐞 Bug - Race Condition Risk: Implement file locking using FileStream with exclusive access, or use a proper database/queue system for concurrent access safety.

Suggested change
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 }));
using (var fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None))
{
if (fileStream.Length > 0)
{
try
{
fileStream.Position = 0;
payloads = await JsonSerializer.DeserializeAsync<List<object>>(fileStream) ?? new();
}
catch { }
}
payloads.Add(payload);
fileStream.SetLength(0);
fileStream.Position = 0;
await JsonSerializer.SerializeAsync(fileStream, payloads, new JsonSerializerOptions { WriteIndented = true });
}
}

Comment on lines +74 to +75
} 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.

🧹 Maintainability - Poor Error Handling: Use specific exception types, implement proper logging with appropriate log levels, and return meaningful error messages without exposing internal details.

Suggested change
} catch (Exception e) {
e.printStackTrace();
} catch (java.sql.SQLException e) {
logger.error("Database error occurred while storing order for user: {}", username, e);

Copy link

gitstream-cm bot commented Jun 29, 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 29, 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 29, 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 8 additions & 0 deletions
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/app.js

Activity based on git-commit:

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

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/index.html

Activity based on git-commit:

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

Knowledge based on git-blame:
amitmohleji: 100%

frontend/server.js

Activity based on git-commit:

amitmohleji b-sims
JUN 37 additions & 0 deletions
MAY
APR
MAR
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
APR 54 additions & 0 deletions
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
APR 75 additions & 0 deletions
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
APR 86 additions & 0 deletions
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