-
Notifications
You must be signed in to change notification settings - Fork 96
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
[DSD-4199] #329
base: release-1.2.0.x
Are you sure you want to change the base?
[DSD-4199] #329
Conversation
#325) * [DSD-4267] removed mock-sdk-jpeg-extractor functionality from mosip-mock-services repo Signed-off-by: techno-467 <[email protected]> * [DSD-4267] removed mock-sdk-jpeg-extractor functionality from mosip-mock-services repo Signed-off-by: techno-467 <[email protected]> * [DSD-4267] removed mock-sdk-jpeg-extractor functionality from mosip-mock-services repo Signed-off-by: techno-467 <[email protected]> --------- Signed-off-by: techno-467 <[email protected]>
…e floating point numbers Signed-off-by: JanardhanBS-SyncByte <[email protected]>
[MOSIP-31258] The attributes requestedScore and qualityScore should be floating point numbers
…e floating point numbers with return type String Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: Sowmya Ujjappa Banakar <[email protected]>
MOSIP-31498 code fix
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
…iometricsdk.version Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
[MOSIP-33587] Merge develop from develop-java21
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: Chandra Keshav Mishra <[email protected]>
[DSD-5620] Update README.md
[MOSIP-33587] Merge develop from develop-java21
Signed-off-by: ckm007 <[email protected]>
Signed-off-by: ckm007 <[email protected]>
Signed-off-by: ckm007 <[email protected]>
[MOSIP-34233]
Signed-off-by: GitHub <[email protected]> Co-authored-by: Prafulrakhade <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]> Co-authored-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: Praful Rakhade <[email protected]>
Signed-off-by: Praful Rakhade <[email protected]>
[MOSIP-35160] Updated URL from https://github.com/mosip/mosip-infra/b…
[MOSIP-35160] Updated URL from https://github.com/mosip/mosip-infra/b…
Signed-off-by: Rakshithb1 <[email protected]>
[MOSIP-35892] Updated helm charts to add range
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
[MOSIP-37359]Update readme
* Constructs the controller with the provided ProxyAbisConfigService instance. | ||
* | ||
* @param proxyAbisConfigService The service instance to be used by this | ||
* controller. |
Check warning
Code scanning / CodeQL
Cross-site scripting Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 29 days ago
To fix the cross-site scripting vulnerability, we need to ensure that any user-provided data is properly sanitized or encoded before being included in the response. The best way to fix this issue is to use a library that provides HTML encoding to escape any potentially harmful characters.
In this case, we can use the StringEscapeUtils
class from the Apache Commons Text library to encode the expectation.getId()
value before including it in the response.
-
Copy modified line R25 -
Copy modified lines R72-R73
@@ -24,2 +24,3 @@ | ||
import java.util.Map; | ||
import org.apache.commons.text.StringEscapeUtils; | ||
|
||
@@ -70,3 +71,4 @@ | ||
proxyAbisConfigService.setExpectation(expectation); | ||
return new ResponseEntity<>("Successfully inserted expectation " + expectation.getId(), HttpStatus.OK); | ||
String safeExpectationId = StringEscapeUtils.escapeHtml4(expectation.getId()); | ||
return new ResponseEntity<>("Successfully inserted expectation " + safeExpectationId, HttpStatus.OK); | ||
} catch (Exception exp) { |
-
Copy modified lines R69-R73
@@ -68,2 +68,7 @@ | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-text</artifactId> | ||
<version>1.12.0</version> | ||
</dependency> | ||
<dependency> |
Package | Version | Security advisories |
org.apache.commons:commons-text (maven) | 1.12.0 | None |
logger.info("Fetching CBEFF for reference URL-" + CBEFF_URL); | ||
ResponseEntity<String> cbeffResp = restTemplate.exchange(CBEFF_URL, HttpMethod.GET, null, String.class); | ||
logger.info("Fetching CBEFF for reference URL-" + cbeffURL); | ||
ResponseEntity<String> cbeffResp = restTemplate.exchange(cbeffURL, HttpMethod.GET, null, String.class); |
Check failure
Code scanning / CodeQL
Server-side request forgery Critical
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 30 days ago
To fix the SSRF vulnerability, we need to ensure that the user-provided URL is validated against a list of authorized URLs or restricted to a particular host or URL prefix. This can be achieved by maintaining a list of valid URLs and checking the user input against this list before making the HTTP request.
- Create a list of authorized URLs.
- Validate the user-provided URL against this list.
- If the URL is not in the list, throw an exception or handle the error appropriately.
-
Copy modified lines R1-R5 -
Copy modified line R139 -
Copy modified lines R171-R195
@@ -1,2 +1,6 @@ | ||
package io.mosip.proxy.abis.service.impl; | ||
package io.mosip.proxy.abis.service.impl; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
@@ -134,3 +138,3 @@ | ||
} | ||
cbeffURL = ire.getReferenceURL(); | ||
cbeffURL = validateURL(ire.getReferenceURL()); | ||
InsertEntity ie = new InsertEntity(ire.getId(), ire.getVersion(), ire.getRequestId(), ire.getRequesttime(), | ||
@@ -166,3 +170,27 @@ | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Validates the given URL against a list of authorized URLs. | ||
* | ||
* @param url the URL to validate | ||
* @return the validated URL if it is authorized | ||
* @throws RequestException if the URL is not authorized | ||
*/ | ||
private String validateURL(String url) throws RequestException { | ||
List<String> authorizedURLs = Arrays.asList( | ||
"http://example.com/valid1", | ||
"http://example.com/valid2" | ||
); | ||
try { | ||
URL parsedURL = new URL(url); | ||
if (authorizedURLs.contains(parsedURL.toString())) { | ||
return url; | ||
} else { | ||
throw new RequestException(FailureReasonsConstants.UNAUTHORIZED_URL); | ||
} | ||
} catch (MalformedURLException e) { | ||
throw new RequestException(FailureReasonsConstants.INVALID_URL_FORMAT); | ||
} | ||
} | ||
|
@@ -312,28 +509,44 @@ | |||
return hexString.toString(); | |||
} | |||
|
|||
/** | |||
* Finds potential duplicate biometric data based on the provided | |||
* IdentityRequest. |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
This path depends on a
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 30 days ago
To fix the problem, we need to validate the user-provided filename to ensure it does not contain any path traversal characters or sequences. This can be done by checking for the presence of "..", "/", or "\" in the filename. If any of these characters or sequences are found, we should reject the input.
The best way to fix the problem without changing existing functionality is to add a validation step before using the filename to construct the file path. This validation will ensure that the filename is safe to use.
-
Copy modified lines R790-R800
@@ -789,9 +789,13 @@ | ||
byte[] bytes = uploadedFile.getBytes(); | ||
Path path = Paths.get(keystoreFilePath.toString(), uploadedFile.getOriginalFilename()); | ||
|
||
File keyFile = new File(path.toString()); | ||
File parent = keyFile.getParentFile(); | ||
if (parent != null && !parent.exists() && !parent.mkdirs()) { | ||
throw new IllegalStateException("Couldn't create dir: " + parent); | ||
} | ||
String originalFilename = uploadedFile.getOriginalFilename(); | ||
if (originalFilename.contains("..") || originalFilename.contains("/") || originalFilename.contains("\\")) { | ||
throw new IllegalArgumentException("Invalid filename"); | ||
} | ||
Path path = Paths.get(keystoreFilePath.toString(), originalFilename); | ||
|
||
File keyFile = new File(path.toString()); | ||
File parent = keyFile.getParentFile(); | ||
if (parent != null && !parent.exists() && !parent.mkdirs()) { | ||
throw new IllegalStateException("Couldn't create dir: " + parent); | ||
} | ||
boolean fileCreated = keyFile.createNewFile(); |
@@ -312,28 +509,44 @@ | |||
return hexString.toString(); | |||
} | |||
|
|||
/** | |||
* Finds potential duplicate biometric data based on the provided | |||
* IdentityRequest. |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
This path depends on a
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 30 days ago
To fix the problem, we need to validate the user-provided filename to ensure it does not contain any path traversal sequences or invalid characters. We can achieve this by checking for the presence of "..", "/", and "\" in the filename and rejecting the input if any of these are found. Additionally, we should ensure that the filename is a single path component and does not contain any directory separators.
Steps to fix:
- Validate the
uploadedFile.getOriginalFilename()
to ensure it does not contain any path traversal sequences or invalid characters. - Reject the input if the validation fails and throw an appropriate exception.
-
Copy modified lines R790-R800
@@ -789,9 +789,13 @@ | ||
byte[] bytes = uploadedFile.getBytes(); | ||
Path path = Paths.get(keystoreFilePath.toString(), uploadedFile.getOriginalFilename()); | ||
|
||
File keyFile = new File(path.toString()); | ||
File parent = keyFile.getParentFile(); | ||
if (parent != null && !parent.exists() && !parent.mkdirs()) { | ||
throw new IllegalStateException("Couldn't create dir: " + parent); | ||
} | ||
String originalFilename = uploadedFile.getOriginalFilename(); | ||
if (originalFilename.contains("..") || originalFilename.contains("/") || originalFilename.contains("\\")) { | ||
throw new IllegalArgumentException("Invalid filename"); | ||
} | ||
Path path = Paths.get(keystoreFilePath.toString(), originalFilename); | ||
|
||
File keyFile = new File(path.toString()); | ||
File parent = keyFile.getParentFile(); | ||
if (parent != null && !parent.exists() && !parent.mkdirs()) { | ||
throw new IllegalStateException("Couldn't create dir: " + parent); | ||
} | ||
boolean fileCreated = keyFile.createNewFile(); |
@@ -514,33 +794,32 @@ | |||
if (parent != null && !parent.exists() && !parent.mkdirs()) { | |||
throw new IllegalStateException("Couldn't create dir: " + parent); | |||
} | |||
keyFile.createNewFile(); | |||
boolean fileCreated = keyFile.createNewFile(); |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
This path depends on a
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 30 days ago
To fix the problem, we need to validate the filename obtained from uploadedFile.getOriginalFilename()
to ensure it does not contain any path separators or parent directory references. This can be done by checking for the presence of characters like /
, \
, or ..
in the filename. If any of these characters are found, we should reject the input and throw an exception.
-
Copy modified lines R790-R802
@@ -789,11 +789,15 @@ | ||
byte[] bytes = uploadedFile.getBytes(); | ||
Path path = Paths.get(keystoreFilePath.toString(), uploadedFile.getOriginalFilename()); | ||
|
||
File keyFile = new File(path.toString()); | ||
File parent = keyFile.getParentFile(); | ||
if (parent != null && !parent.exists() && !parent.mkdirs()) { | ||
throw new IllegalStateException("Couldn't create dir: " + parent); | ||
} | ||
boolean fileCreated = keyFile.createNewFile(); | ||
Files.write(path, bytes); | ||
String originalFilename = uploadedFile.getOriginalFilename(); | ||
if (originalFilename.contains("..") || originalFilename.contains("/") || originalFilename.contains("\\")) { | ||
throw new IllegalArgumentException("Invalid filename"); | ||
} | ||
Path path = Paths.get(keystoreFilePath.toString(), originalFilename); | ||
|
||
File keyFile = new File(path.toString()); | ||
File parent = keyFile.getParentFile(); | ||
if (parent != null && !parent.exists() && !parent.mkdirs()) { | ||
throw new IllegalStateException("Couldn't create dir: " + parent); | ||
} | ||
boolean fileCreated = keyFile.createNewFile(); | ||
Files.write(path, bytes); | ||
|
} catch (RuntimeException exp) { | ||
logger.error(String.format("Exception while getting expectation: %s",request)); | ||
throw exp; | ||
return new ResponseEntity<>("Successfully inserted expectation " + expectation.getRId(), HttpStatus.OK); |
Check warning
Code scanning / CodeQL
Cross-site scripting Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 30 days ago
To fix the problem, we need to ensure that any user-provided data included in the HTTP response is properly sanitized or encoded to prevent XSS attacks. In this case, we can use the HtmlUtils.htmlEscape
method from the org.springframework.web.util
package to escape the expectation.getRId()
value before including it in the response.
-
Copy modified line R2 -
Copy modified lines R138-R139
@@ -1,2 +1,3 @@ | ||
package io.mosip.mock.mv.controller; | ||
import org.springframework.web.util.HtmlUtils; | ||
|
||
@@ -136,3 +137,4 @@ | ||
mockMvDecisionService.setExpectation(expectation); | ||
return new ResponseEntity<>("Successfully inserted expectation " + expectation.getRId(), HttpStatus.OK); | ||
String escapedRId = HtmlUtils.htmlEscape(expectation.getRId()); | ||
return new ResponseEntity<>("Successfully inserted expectation " + escapedRId, HttpStatus.OK); | ||
} catch (Exception exp) { |
if (expectation.getRId() != null) | ||
return new ResponseEntity<>(mockMvDecisionService.getExpectation(rid).toString(), HttpStatus.OK); | ||
else { | ||
return new ResponseEntity<>("No expectation set for given rid:" + rid, HttpStatus.OK); |
Check warning
Code scanning / CodeQL
Cross-site scripting Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 29 days ago
To fix the cross-site scripting vulnerability, we need to ensure that any user-provided input is properly sanitized or encoded before being included in the response. In this case, we can use the StringEscapeUtils
class from the Apache Commons Text library to escape the rid
parameter before including it in the response.
- Add the necessary import for
StringEscapeUtils
. - Escape the
rid
parameter before including it in the response.
-
Copy modified line R33 -
Copy modified line R186
@@ -32,2 +32,3 @@ | ||
import jakarta.validation.Valid; | ||
import org.apache.commons.text.StringEscapeUtils; | ||
|
||
@@ -184,3 +185,3 @@ | ||
else { | ||
return new ResponseEntity<>("No expectation set for given rid:" + rid, HttpStatus.OK); | ||
return new ResponseEntity<>("No expectation set for given rid:" + StringEscapeUtils.escapeHtml4(rid), HttpStatus.OK); | ||
} |
-
Copy modified lines R70-R74
@@ -69,2 +69,7 @@ | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-text</artifactId> | ||
<version>1.12.0</version> | ||
</dependency> | ||
<dependency> |
Package | Version | Security advisories |
org.apache.commons:commons-text (maven) | 1.12.0 | None |
logger.info("Delete expectation: {}", rid); | ||
try { | ||
mockMvDecisionService.deleteExpectation(rid); | ||
return new ResponseEntity<>("Successfully deleted expectation " + rid, HttpStatus.OK); |
Check warning
Code scanning / CodeQL
Cross-site scripting Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 29 days ago
To fix the cross-site scripting vulnerability, we need to ensure that any user-provided input is properly sanitized or encoded before being included in the response. In this case, we can use the HtmlUtils.htmlEscape
method from the org.springframework.web.util
package to escape the rid
parameter before including it in the response.
-
Copy modified line R2 -
Copy modified line R215
@@ -1,2 +1,3 @@ | ||
package io.mosip.mock.mv.controller; | ||
import org.springframework.web.util.HtmlUtils; | ||
|
||
@@ -213,3 +214,3 @@ | ||
mockMvDecisionService.deleteExpectation(rid); | ||
return new ResponseEntity<>("Successfully deleted expectation " + rid, HttpStatus.OK); | ||
return new ResponseEntity<>("Successfully deleted expectation " + HtmlUtils.htmlEscape(rid), HttpStatus.OK); | ||
} catch (Exception exp) { |
* [MOSIP-37853]added skip for deployment in pom Signed-off-by: JanardhanBS-SyncByte <[email protected]> * [MOSIP-37853]added skip for deployment in pom Signed-off-by: JanardhanBS-SyncByte <[email protected]> --------- Signed-off-by: JanardhanBS-SyncByte <[email protected]> Co-authored-by: JanardhanBS-SyncByte <[email protected]>
No description provided.