Java rest api - #1063
Conversation
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: Richard Salac <richard.salac@broadcom.com>
Signed-off-by: Richard Salac <richard.salac@broadcom.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: Richard Salac <richard.salac@broadcom.com>
Signed-off-by: Richard Salac <richard.salac@broadcom.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: Richard Salac <richard.salac@broadcom.com>
# Conflicts: # native/java/app/src/main/java/org/zowe/zowex/ffm/ZjbBindings.java # native/java/app/src/main/java/org/zowe/zowex/ffm/ZusfBindings.java
Signed-off-by: ac892247 <a.chmelo@gmail.com>
…ndler Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Signed-off-by: ac892247 <a.chmelo@gmail.com>
# Conflicts: # .gitignore
Signed-off-by: ac892247 <a.chmelo@gmail.com>
| { | ||
| int rc = EINVAL; | ||
| char *platformUser = jstring_to_ebcdic(env, user); | ||
| char *platformPassword = jstring_to_ebcdic(env, password); |
There was a problem hiding this comment.
This variable is allocated but only platformUser and platformApplId are passed to free_if_not_null. Does this mean that every login leaks an un-scrubbed copy of the user's plaintext password? If so, could we scrub it and then free it?
For example:
if (platformPassword != NULL) {
size_t len = strlen(platformPassword);
memset(platformPassword, 0, len); // scrub before free
free(platformPassword);
}| #define THLIAPPLIDLEN 0x052 | ||
| #define THLIAPPLID 0x070 | ||
|
|
||
| int lastErrno2 = 0; |
There was a problem hiding this comment.
This is a process-level global and not thread-local. Couldn't two concurrent requests race on this variable? See comment below about Java_org_zowe_zowex_zos_security_jni_Secur_createSecurityEnvironment
| } | ||
| free_if_not_null(platformUser); | ||
| free_if_not_null(platformApplId); | ||
| return rc; |
There was a problem hiding this comment.
We could pack rc and errno2 into a single jlong to avoid the process-level global. We could defer this to a future PR if this requires out-of-scope changes.
| memset(thliApplid, ' ', 8); | ||
| origApplid[8] = 0; | ||
| memcpy(origApplid, thliApplid, 8); | ||
| memcpy(thliApplid, applid, applidLength); |
There was a problem hiding this comment.
Should we check the length against the SAF THLI field's actual size? Otherwise, copying data w/ a length greater than the THLI field may corrupt adjacent memory or crash the JVM.
For example:
char *applid = jstring_to_ebcdic(env, jApplid);
if (applid == NULL) {
return -1; // conversion failed
}
const int applidLength = strlen(applid);
if (applidLength > 8) {
free_if_not_null(applid);
return -1; // reject anything that won't fit the THLI field
}| @Tag(name = "Security") | ||
| @RestController | ||
| @RequestMapping("/api/v1/securityTest") | ||
| public class SecurityContextController { |
There was a problem hiding this comment.
Correct me if I'm missing something, but is it true that any authenticated caller could use this controller to query whether any user has a given SAF access level to a specific resource?
For context, the class comment says "Troubleshooting only" , but there's no @Profile or admin-only guard, suggesting it could be reached by any authenticated caller in production.
| } | ||
| } | ||
| // Free memory | ||
| ZdsCApi.zds_c_free_list_response(responsePtr); |
There was a problem hiding this comment.
If any of the readString calls fail in the above loop, the native block is never freed and it jumps straight to the catch on lines 77-80. Should we add a small helper to guarantee cleanup regardless of the outcome?
This same pattern occurs in other functions within this file, hence the suggestion for the helper.
| return null; | ||
| } | ||
| // Reinterpret the segment to maximum size so getString can find the null terminator | ||
| return segment.reinterpret(Long.MAX_VALUE).getString(0); |
There was a problem hiding this comment.
Not opposed to using Long.MAX_VALUE, but is there a smaller and more reasonable upper bound for string read?
The Long.MAX_VALUE may allow for an unbounded memory scan, or possible segmentation fault into unmapped pages of memory.
Signed-off-by: ac892247 <a.chmelo@gmail.com>
Requested changes were implemented, taking another look
|
I see two critical CodeQL issues flagged around use of |
|
Could we add a readme for building & running the Java server please? I assume it involves the gradle tasks, but would be nice to have a guide checked in for the basics |
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: achmelo <37397715+achmelo@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: achmelo <37397715+achmelo@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: achmelo <37397715+achmelo@users.noreply.github.com>
traeok
left a comment
There was a problem hiding this comment.
Thanks for addressing the CodeQL issues.
Echoing @CBforZ suggestion: can you add a Markdown file with information on how to set up and use the Java REST API?
Also, some steps in How to Test would be greatly appreciated - sorry, I'm a bit of a newb when it comes to Java + z/OS - but it would also benefit other folks that are reviewing 😋
|
Hi @achmelo, I was wondering if you had a chance to review/address the latest round of feedback? Primarily around the readme + documentation for how to get the server set up 🙂 thanks! |
sorry for late response, I was occupied with another work. I have added readme with details that I remember. Hope I didn't miss anything. Please, let me know if something doesn't work. |
no worries @achmelo , thanks for the updates! I'll take a look |
| std::string jobid_str = jobid ? jobid : ""; | ||
| a2e_inplace(jobid_str); | ||
|
|
||
| int rc = zjb_read_jobs_output_by_key(&zjb, jobid_str, key, out_response); |
There was a problem hiding this comment.
Was renamed to zjb_read_job_content_by_key , needs that update to compile after updating from the main branch
Signed-off-by: CBforZ <chris.boehm@broadcom.com>
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
|




What It Does
Spring REST API for zowex that integrates with API ML.
How to Test
Review Checklist
I certify that I have:
Additional Comments