-
-
Notifications
You must be signed in to change notification settings - Fork 479
Add ability to download transaction meter values as CSV #2044
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,7 @@ | |
| private static final String TRANSACTIONS_PATH = "/transactions"; | ||
| private static final String TRANSACTION_STOP_PATH = "/transactions/stop/{transactionPk}"; | ||
| private static final String TRANSACTIONS_DETAILS_PATH = "/transactions/details/{transactionPk}"; | ||
| private static final String TRANSACTIONS_DETAILS_METER_VALUES_CSV_PATH = TRANSACTIONS_DETAILS_PATH + "/meterValues.csv"; | ||
|
Check failure on line 67 in src/main/java/de/rwth/idsg/steve/web/controller/TransactionsReservationsController.java
|
||
| private static final String TRANSACTIONS_QUERY_PATH = "/transactions/query"; | ||
| private static final String RESERVATIONS_PATH = "/reservations"; | ||
| private static final String RESERVATIONS_QUERY_PATH = "/reservations/query"; | ||
|
|
@@ -94,6 +95,17 @@ | |
| return "data-man/transactionDetails"; | ||
| } | ||
|
|
||
| @RequestMapping(value = TRANSACTIONS_DETAILS_METER_VALUES_CSV_PATH) | ||
| public void getTransactionDetailsMeterValuesCsv(@PathVariable("transactionPk") int transactionPk, | ||
| HttpServletResponse response) throws IOException { | ||
| String fileName = "transaction_%s_meter_values.csv".formatted(transactionPk); | ||
| String headerKey = "Content-Disposition"; | ||
| String headerValue = "attachment; filename=\"%s\"".formatted(fileName); | ||
| response.setContentType("text/csv"); | ||
| response.setHeader(headerKey, headerValue); | ||
| transactionService.writeTransactionMeterValuesCSV(transactionPk, response.getWriter()); | ||
| } | ||
|
Comment on lines
+98
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Meter csv leaks exception details The new CSV download endpoint does not handle not-found/serialization failures and will fall back to
the global MVC error page, which renders ${exception}/${exception.cause} to the client
(information leakage) instead of a client-safe error response.
Agent Prompt
|
||
|
|
||
| @RequestMapping(value = TRANSACTIONS_QUERY_PATH) | ||
| public String getTransactionsQuery(@Valid @ModelAttribute(PARAMS) TransactionQueryForm params, | ||
| BindingResult result, Model model, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Csv formula injection
🐞 Bug⛨ SecurityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools