-
Notifications
You must be signed in to change notification settings - Fork 0
Application Name Mapping #50
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
base: 1.0.35_pre_release
Are you sure you want to change the base?
Conversation
| var uniqueAppIds = []; | ||
|
|
||
| // Collect all unique application IDs from relevant projects | ||
| for (var i = 0; i < projects.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional : var project = projects[i]; and var appId = appIds[j]; and then use project and appID as below.
var uniqueAppIds = [];
for (var i = 0; i < projects.length; i++) {
var project = projects[i];
if (project.createdAt > createdDate) {
var appIds = project.applicationIds || [];
for (var j = 0; j < appIds.length; j++) {
var appId = appIds[j];
if (uniqueAppIds.indexOf(appId) === -1) {
uniqueAppIds.push(appId);
}
}
}
}
| var appNameMap = this.UTIL.getApplicationMapName(this.IMPLEMENTATION, appIdParam); | ||
| } | ||
|
|
||
| for (var item in projects) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any chance that project will be null?
| if (null != projects[item].applicationIds && projects[item].applicationIds.length > 0) | ||
| applicationIds = projects[item].applicationIds.toString(); | ||
| // Build <applications> block | ||
| if (projects[item].applicationIds && projects[item].applicationIds.length > 0 && appIdParam && appIdParam.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: repeatedly using projects[item], which makes the code harder to read and maintain
Define a project variable once
var project = projects[item];
| }); | ||
| } | ||
| } | ||
| if (appList.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary check for appList.length, this can be achieve with below code as well.
for (var i = 0; i < appList.length; i++) {
...
}
| // Make API call for the current 200 app IDs | ||
| var responseBody = this._makeRestApiCall(apibaseurl, configId, token, query, "get"); | ||
| var body = responseBody.getBody(); | ||
| var result = JSON.parse(body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do the validation of body?
| var applications = result.applications || []; | ||
|
|
||
| // Map application ID → Name | ||
| for (var k = 0; k < applications.length; k++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional : Can be replace with below.
applications.forEach(function(app) {
appNameMap[app.id] = app.name;
});
Application Name mapping along with Id to Source Additional Info field of Discovered Application Table
Jira Link: [https://checkmarx.atlassian.net/browse/CXSER-889]