Skip to content

[PHEE-684] Reporting CRUD APIs - #120

Open
atul18102003 wants to merge 3 commits into
openMF:masterfrom
atul18102003:master
Open

[PHEE-684] Reporting CRUD APIs#120
atul18102003 wants to merge 3 commits into
openMF:masterfrom
atul18102003:master

Conversation

@atul18102003

@atul18102003 atul18102003 commented Jun 19, 2024

Copy link
Copy Markdown

Description

PHEE-684 Reporting CRUD APIs

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Followed the PR title naming convention mentioned above.

  • Design related bullet points or design document link related to this PR added in the description above.

  • Updated corresponding Postman Collection or Api documentation for the changes in this PR.

  • Create/update unit or integration tests for verifying the changes made.

  • Add required Swagger annotation and update API documentation with details of any API changes if applicable

  • Followed the naming conventions as given in https://docs.google.com/document/d/1Q4vaMSzrTxxh9TS0RILuNkSkYCxotuYk1Xe0CMIkkCU/edit?usp=sharing

@jit-ci

jit-ci Bot commented Jun 19, 2024

Copy link
Copy Markdown

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@jit-ci jit-ci Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❌ Jit has detected 1 important finding in this PR that you should review.
The finding is detailed below as a comment.
It’s highly recommended that you fix this security issue before merge.

# password: "ethieTieCh8ahv"
# password: lavanya
password: "ethieTieCh8ahv"
common:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Security control: Secret Detection

Type: Hashicorp-Tf-Password

Description: Identified a HashiCorp Terraform password field, risking unauthorized infrastructure configuration and security breaches.

Severity: HIGH



Jit Bot commands and options (e.g., ignore issue)

You can trigger Jit actions by commenting on this PR review:

  • #jit_ignore_fp Ignore and mark this specific single instance of finding as “False Positive”
  • #jit_ignore_accept Ignore and mark this specific single instance of finding as “Accept Risk”
  • #jit_undo_ignore Undo ignore command

import lombok.*;

import javax.persistence.*;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Using wildcards is a bad practice.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed it


public ReportRequest createReport(@Valid ReportRequest reportRequest) {

if (reportRequest.getReportName() == null || reportRequest.getReportName().isEmpty()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Many important validations are missing, like the query field is not null, and the query has no data modification statement.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added the validations

@Table(name = "REPORTREQUEST")
@Getter
@Setter
public class ReportRequest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can the validation annotations for checks like not null be put as annotations to the relevant fields in the request DTO itself?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

@@ -0,0 +1,64 @@
package org.apache.fineract.ReportApi;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A basic naming convention is to have package names to be in lowercase.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

import javax.validation.Valid;
import java.util.List;

@RestController

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Class level Request Mapping annotation missing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

@RestController
public class ReportController {

@Autowired

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Annotations to support OAS are missing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

return ResponseEntity.status(HttpStatus.CREATED).body(createdReport);
} catch (ValidationException e) {

return ResponseEntity.badRequest().build();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Too Generic validation handling.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

public ReportRequest updateReport(Long id, ReportRequest updatedReportRequest) {
Optional<ReportRequest> optionalReport = reportRepository.findById(id);
if (optionalReport.isPresent()) {
ReportRequest existingReport = optionalReport.get();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can every field be updated for a report as per the API specifications?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

existingReport.setReportType(updatedReportRequest.getReportType());
existingReport.setReportSubType(updatedReportRequest.getReportSubType());
existingReport.setReportCategory(updatedReportRequest.getReportCategory());
existingReport.setDescription(updatedReportRequest.getDescription());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it necessary to include all field values in the update API request? If so, this design seems inefficient. Only the specific field that requires updating should be included in the request. If not, then why are you setting every other field to null?
The design needs to be corrected here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants