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

POST to /api/collections/{}/reviews/{} with >1 Review for same RuleId returns 400 #1008

Closed
cd-rite opened this issue May 27, 2023 · 1 comment
Assignees
Labels

Comments

@cd-rite
Copy link
Collaborator

cd-rite commented May 27, 2023

This is technically correct! Consider accepting an otherwise acceptable request, but adding the duplicated RuleId to the "rejected" count.
Error happens when executing the createIncomingForPost statement in ReviewService.js with the provided Reviews, violating the Primary Key on RuleId.

To Recreate via the UI-

  • Collection Manage -> Import .ckl:
  • Import these two files together ([remove .txt extension];
    • note: they have different benchmarkIds, suspect this is why they do not get collapsed to 1 review by UI
    • They will import if done individually

Asset_Linux_0251-MS_Windows_10_STIG-V2R4.ckl.txt
Asset_Linux_0251-Windows_10_STIG-V2R3.ckl.txt

  • Or this file alone:

Asset_Linux_0251-Windows_10_STIG-V2R3-combined.ckl.txt

Get API error:

"error": "Duplicate entry 'SV-220697r569187_rule' for key 'incoming.PRIMARY'"

Happens with Watcher as well.
Full UI error below:

{ "name": "ExtRequestError", "method": "POST", "url": "/api/collections/11/reviews/251", "status": 400, "responseText": "{\"error\":\"Duplicate entry 'SV-220697r569187_rule' for key 'incoming.PRIMARY'\"}", "responseHeaders": "access-control-allow-origin: *\r\nconnection: keep-alive\r\ncontent-length: 78\r\ncontent-type: application/json; charset=utf-8\r\ndate: Sat, 27 May 2023 19:31:49 GMT\r\netag: W/\"4e-pzeLqMM1bWSAXpn3pB5o0HrRcqo\"\r\nkeep-alive: timeout=5\r\nvary: Accept-Encoding\r\nx-powered-by: Express\r\n", "tokenParsed": { "exp": "1685216176 (2023-05-27 15:36:16)", "iat": "1685215876 (2023-05-27 15:31:16)", "auth_time": "1685215876 (2023-05-27 15:31:16)", "jti": "ed172811-303e-4433-bc9d-c87f39bff453", "iss": "http://localhost:8080/realms/stigman", "aud": "realm-management", "sub": "bf87a16f-39e6-46d9-8971-f0ef51dd3f85", "typ": "Bearer", "azp": "stig-manager", "nonce": "0212eec8-ad64-44be-905c-d1a70d10cd59", "session_state": "3d1c362c-f4bf-482a-9117-5f86046a4085", "realm_access": { "roles": [ "create_collection", "admin", "user" ] }, "resource_access": { "realm-management": { "roles": [ "view-users", "query-groups", "query-users" ] } }, "scope": "stig-manager:collection stig-manager:stig:read stig-manager:user:read stig-manager:op stig-manager:user stig-manager:stig", "sid": "3d1c362c-f4bf-482a-9117-5f86046a4085", "name": "Admin Burke", "preferred_username": "admin", "given_name": "Admin", "family_name": "Burke" }, "detail": { "message": "POST /api/collections/11/reviews/251\n{\"error\":\"Duplicate entry 'SV-220697r569187_rule' for key 'incoming.PRIMARY'\"}", "response": { "tId": 13, "status": 400, "statusText": "Bad Request", "responseText": "{\"error\":\"Duplicate entry 'SV-220697r569187_rule' for key 'incoming.PRIMARY'\"}", "responseXML": null }, "options": { "url": "/api/collections/11/reviews/251", "method": "POST", "headers": { "Content-Type": "application/json;charset=utf-8", "Authorization": "<removed>", "X-Requested-With": "XMLHttpRequest" }, "jsonData": [ { "ruleId": "SV-220697r569187_rule", "result": "fail", "detail": "xxxxxxxxxxxxxxxxxxxxxxx", "comment": null, "resultEngine": null, "status": "saved" }, { "ruleId": "SV-220697r569187_rule", "result": "fail", "detail": "monitor-Manager", "comment": null, "resultEngine": null, "status": "saved" } ] } }, "message": "Ext.Ajax.request() failed", "stack": "ExtRequestError: Ext.Ajax.request() failed\n at Ext.data.Connection.requestPromise (http://localhost:64001/js/overrides.js:297:19)\n at async importReviewArray (http://localhost:64001/js/SM/ReviewsImport.js:2709:34)\n at async sb.showImportProgress [as addHandler] (http://localhost:64001/js/SM/ReviewsImport.js:2628:61)\n at async sb.handler (http://localhost:64001/js/SM/ReviewsImport.js:1606:17)", "env": { "version": "1.3.6", "apiBase": "/api", "welcome": { "image": "", "title": "", "message": "", "link": "" }, "commit": { "branch": "na", "sha": "na", "tag": "na", "describe": "na" }, "oauth": { "authority": "http://localhost:8080/realms/stigman", "clientId": "stig-manager", "refreshToken": { "disabled": false }, "extraScopes": "", "scopePrefix": "", "claims": { "scope": "scope", "username": "preferred_username", "servicename": "clientId", "name": "name", "privileges": "['realm_access']?.['roles']", "email": "email" } } } }

@cd-rite
Copy link
Collaborator Author

cd-rite commented Nov 1, 2023

Resolved: #1131

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

No branches or pull requests

1 participant