-
Notifications
You must be signed in to change notification settings - Fork 2
feat: introduced an interaction system with NPCs which allows you to rob them #896
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
Conversation
|
|
||
| DispatchItem += `</div></div>`; | ||
|
|
||
| $('.dispatch-holder').prepend(DispatchItem); |
Check failure
Code scanning / CodeQL
Client-side cross-site scripting High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that any user-provided data is properly sanitized or escaped before being inserted into the HTML content. This can be achieved by using a library like DOMPurify to sanitize the input or by manually escaping the data to prevent XSS attacks.
The best way to fix the problem without changing existing functionality is to use DOMPurify to sanitize the user-provided data before it is used to construct the DispatchItem HTML string. This approach ensures that any potentially harmful content is removed, while still allowing safe content to be displayed.
-
Copy modified lines R1-R2 -
Copy modified lines R87-R94 -
Copy modified line R96 -
Copy modified line R98 -
Copy modified line R103 -
Copy modified line R105 -
Copy modified lines R152-R157 -
Copy modified lines R160-R161
| @@ -1 +1,3 @@ | ||
| import DOMPurify from 'dompurify'; | ||
|
|
||
| $(document).ready(() => { | ||
| @@ -84,6 +86,14 @@ | ||
| let DispatchItem; | ||
| const sanitizedCallID = DOMPurify.sanitize(callID); | ||
| const sanitizedDispatchCode = DOMPurify.sanitize(info.dispatchCode); | ||
| const sanitizedDispatchMessage = DOMPurify.sanitize(info.dispatchMessage); | ||
| const sanitizedTime = info['time'] ? DOMPurify.sanitize(info['time']) : null; | ||
| const sanitizedName = info['name'] ? DOMPurify.sanitize(info['name']) : null; | ||
| const sanitizedNumber = info['number'] ? DOMPurify.sanitize(info['number']) : null; | ||
| const sanitizedInformation = info['information'] ? DOMPurify.sanitize(info['information']) : null; | ||
|
|
||
| if (info['isDead']) { | ||
| DispatchItem = `<div class="dispatch-item ${callID} dispatch-item-${info['isDead']} animate__animated"><div class="top-info-holder"><div class="call-id">#${callID}</div><div class="call-code priority-${prio}">${info.dispatchCode}</div><div class="call-name">${info.dispatchMessage}</div></div><div class="bottom-info-holder">`; | ||
| DispatchItem = `<div class="dispatch-item ${sanitizedCallID} dispatch-item-${info['isDead']} animate__animated"><div class="top-info-holder"><div class="call-id">#${sanitizedCallID}</div><div class="call-code priority-${prio}">${sanitizedDispatchCode}</div><div class="call-name">${sanitizedDispatchMessage}</div></div><div class="bottom-info-holder">`; | ||
| } else { | ||
| DispatchItem = `<div class="dispatch-item ${callID} dispatch-item-${isPolice} animate__animated"><div class="top-info-holder"><div class="call-id">#${callID}</div><div class="call-code priority-${prio}">${info.dispatchCode}</div><div class="call-name">${info.dispatchMessage}</div></div><div class="bottom-info-holder">`; | ||
| DispatchItem = `<div class="dispatch-item ${sanitizedCallID} dispatch-item-${isPolice} animate__animated"><div class="top-info-holder"><div class="call-id">#${sanitizedCallID}</div><div class="call-code priority-${prio}">${sanitizedDispatchCode}</div><div class="call-name">${sanitizedDispatchMessage}</div></div><div class="bottom-info-holder">`; | ||
| } | ||
| @@ -92,5 +102,5 @@ | ||
|
|
||
| if (info['time']) { | ||
| if (sanitizedTime) { | ||
| DispatchItem += `<div class="call-bottom-info"><span class="fas fa-clock"></span>${timeAgo( | ||
| info['time'] | ||
| sanitizedTime | ||
| )}</div>`; | ||
| @@ -141,12 +151,12 @@ | ||
|
|
||
| if (info['name'] && info['number']) { | ||
| DispatchItem += `<div class="call-bottom-info"><span class="far fa-id-badge"></span>${info['name']}<span class="fas fa-mobile-alt" style="margin-left: 2vh;"></span>${info['number']}</div>`; | ||
| } else if (info['number']) { | ||
| DispatchItem += `<div class="call-bottom-info"><span class="fas fa-mobile-alt"></span>${info['number']}</div>`; | ||
| } else if (info['name']) { | ||
| DispatchItem += `<div class="call-bottom-info"><span class="far fa-id-badge"></span>${info['name']}</div>`; | ||
| if (sanitizedName && sanitizedNumber) { | ||
| DispatchItem += `<div class="call-bottom-info"><span class="far fa-id-badge"></span>${sanitizedName}<span class="fas fa-mobile-alt" style="margin-left: 2vh;"></span>${sanitizedNumber}</div>`; | ||
| } else if (sanitizedNumber) { | ||
| DispatchItem += `<div class="call-bottom-info"><span class="fas fa-mobile-alt"></span>${sanitizedNumber}</div>`; | ||
| } else if (sanitizedName) { | ||
| DispatchItem += `<div class="call-bottom-info"><span class="far fa-id-badge"></span>${sanitizedName}</div>`; | ||
| } | ||
|
|
||
| if (info['information']) { | ||
| DispatchItem += `<div class="line"></div><div class="call-bottom-info call-bottom-information"><span class="far fa-question-circle"></span>${info['information']}</div>`; | ||
| if (sanitizedInformation) { | ||
| DispatchItem += `<div class="line"></div><div class="call-bottom-info call-bottom-information"><span class="far fa-question-circle"></span>${sanitizedInformation}</div>`; | ||
| } |
-
Copy modified lines R4-R6
| @@ -3,2 +3,5 @@ | ||
| "eslint": "^9.15.0" | ||
| }, | ||
| "dependencies": { | ||
| "dompurify": "^3.2.0" | ||
| } |
| Package | Version | Security advisories |
| dompurify (npm) | 3.2.0 | None |
| <title>QB Dispatch</title> | ||
| <link rel="stylesheet" href="style.css"> | ||
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | ||
| <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> |
Check warning
Code scanning / CodeQL
Inclusion of functionality from an untrusted source Medium
| data.iconColor ? `style = color:${data.iconColor} !important` : null | ||
| }"></i>`; | ||
|
|
||
| option.innerHTML = `${iconElement}<p class="option-label">${data.label}</p>`; |
Check failure
Code scanning / CodeQL
Client-side cross-site scripting High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that any user-provided data is properly sanitized or encoded before being inserted into the DOM. The best way to fix this issue without changing existing functionality is to use a library like DOMPurify to sanitize the data.label value before inserting it into the HTML.
- Install the
DOMPurifylibrary. - Import
DOMPurifyin thecreateOptions.jsfile. - Use
DOMPurifyto sanitize thedata.labelvalue before setting theinnerHTML.
-
Copy modified line R2 -
Copy modified line R23
| @@ -1,2 +1,3 @@ | ||
| import { fetchNui } from "./fetchNui.js"; | ||
| import DOMPurify from 'dompurify'; | ||
|
|
||
| @@ -21,3 +22,3 @@ | ||
|
|
||
| option.innerHTML = `${iconElement}<p class="option-label">${data.label}</p>`; | ||
| option.innerHTML = `${iconElement}<p class="option-label">${DOMPurify.sanitize(data.label)}</p>`; | ||
| option.className = "option-container"; |
-
Copy modified lines R4-R6
| @@ -3,2 +3,5 @@ | ||
| "eslint": "^9.15.0" | ||
| }, | ||
| "dependencies": { | ||
| "dompurify": "^3.2.0" | ||
| } |
| Package | Version | Security advisories |
| dompurify (npm) | 3.2.0 | None |
Fixes #[issue_no]
All Submissions:
Please describe the changes this PR makes and why it should be merged:
Discord username (if different from GitHub):