Skip to content
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

- solved #840 #849

Merged

Conversation

jiachen1120
Copy link
Contributor

issue: #840

  • audit request if bodyHandler enabled
  • audit query parameters if request contains it
  • audit response on error

- audit request if bodyHandler enabled
- audit query parameters if request contains it
- audit response on error
@codecov-io
Copy link

Codecov Report

Merging #849 (f2c1748) into 1.6.x (b9033a3) will increase coverage by 0.03%.
The diff coverage is 62.79%.

Impacted file tree graph

@@             Coverage Diff              @@
##              1.6.x     #849      +/-   ##
============================================
+ Coverage     48.96%   49.00%   +0.03%     
- Complexity     1941     1951      +10     
============================================
  Files           267      267              
  Lines         12081    12112      +31     
  Branches       1692     1704      +12     
============================================
+ Hits           5916     5936      +20     
- Misses         5462     5463       +1     
- Partials        703      713      +10     
Impacted Files Coverage Δ Complexity Δ
...rc/main/java/com/networknt/audit/AuditHandler.java 61.11% <60.97%> (+1.78%) 23.00 <9.00> (+10.00)
.../src/main/java/com/networknt/body/BodyHandler.java 73.77% <100.00%> (ø) 13.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9033a3...f2c1748. Read the comment docs.

Copy link
Contributor

@stevehu stevehu left a comment

Choose a reason for hiding this comment

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

I have reviewed the PR and it looks good to me. @miklish Could you please review and approve it? Thanks.

- serviceId

# Request Body, this is optional and must be set by the service in its implementation
- request
Copy link
Contributor

Choose a reason for hiding this comment

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

can we rename this to requestBody and responseBody? Just saying request sounds like it will audit the whole request including query params, path params, cookies etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing out, I also think renaming would be better. But seems these names have been used in previous versions. If we change them now, it may cause backward compatibility. People who previously used these names to audit requests may not be able to continue auditing them if they don't change their configuration. @stevehu Do you think we can change it?

Copy link
Contributor

@stevehu stevehu Dec 4, 2020

Choose a reason for hiding this comment

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

I think it makes sense to rename it to clearly define what is the audited object. Regarding the backward compatibility in the config, we can mention that in the next release notes. It is not a coding issue but only the configuration file and it is easier for users to adjust. Thank you for pointing it out. We need to update the document to refect the change in this PR as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. Will rename them.

- request

# Response payload, this is optional and must be set by the service in its implementation
- response
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as comment for request

- response

# Request query parameters
- queryParameters
Copy link
Contributor

Choose a reason for hiding this comment

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

you added queryParams, what if somebody wants to audit path params and cookies?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing out.

Since my client now only needs audit query parameters, I was limited to audit query parameters before. I think we can try to cover more audit point.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have realized that serviceId is in the audit list but it is not implemented. It is only mentioned in the comment section at the beginning of the handler. When the audit log aggregated to a central location, the serviceId should be the key info. @jiachen1120 Could you please add this to this PR? It should be retrieved from the server.yml file. Let me know if you have questions or concerns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Will do

@stevehu stevehu self-requested a review December 4, 2020 15:28
@stevehu stevehu merged commit a6d9320 into 1.6.x Dec 9, 2020
@stevehu stevehu deleted the feat/#840_request_response_audit_missing_when_auditOnError branch December 9, 2020 16:30
stevehu pushed a commit that referenced this pull request Dec 9, 2020
* - solved #840
- audit request if bodyHandler enabled
- audit query parameters if request contains it
- audit response on error

* - auditing all request components
- auditing serviceId

* - added more test cases
younggwon1 pushed a commit to younggwon1/light-4j that referenced this pull request Feb 10, 2024
* - solved networknt#840
- audit request if bodyHandler enabled
- audit query parameters if request contains it
- audit response on error

* - auditing all request components
- auditing serviceId

* - added more test cases
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.

None yet

4 participants