diff --git a/README.md b/README.md index e02ef3a..09a55d9 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,15 @@ Cloud Insight Add-on for JIRA The Cloud Insight Add-on for JIRA integrates Cloud Insight remediations as JIRA issues, which allows you to configure, manage, and assign issues to JIRA teams. JIRA team members can use the add-on to review, and then dispose assigned remediations. -##Supported JIRA Versions +## Supported JIRA Versions * From 6.3.9 to 6.4.12 the download link [jar file](https://github.com/alertlogic/ci_jira/tree/for_jira_version_6/download). * 7.0.0 the download link [jar file](https://github.com/alertlogic/ci_jira/tree/for_jira_version_7/download) -##Add-on Install User Guide +## Add-on Install User Guide See [Install user guide here](INSTALL.md). -##Add-on Developer Environment Installation +## Add-on Developer Environment Installation Configure the environment as directed in the follow guide: https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project @@ -25,7 +25,7 @@ https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin * In the console, run the following command: `atlas-run` -##Other commands: +## Other commands: * `atlas-run`: installs this add-on into the product, and starts it on localhost * `atlas-debug`: same as `atlas-run,` and allows a debugger to attach at port 5005 diff --git a/download/jira-cloud-insight-7.2.3.0-SNAPSHOT.jar b/download/jira-cloud-insight-7.2.3.0-SNAPSHOT.jar new file mode 100644 index 0000000..971fc8e Binary files /dev/null and b/download/jira-cloud-insight-7.2.3.0-SNAPSHOT.jar differ diff --git a/pom.xml b/pom.xml index ac76ee2..1d9279f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,25 +1,25 @@ - + + 4.0.0 com.alertlogic.plugins.jira.cloudinsight jira-cloud-insight - 7.2.2.8-SNAPSHOT + 7.2.3.0-SNAPSHOT + Alert logic https://www.alertlogic.com/ + cloud-insight-for-jira The Cloud Insight add-on for Jira integrates Cloud Insight remediations as Jira issues, which allows you to configure, manage, and assign issues to Jira teams. Jira team members can use the add-on to review, and then dispose assigned remediations. atlassian-plugin - + com.atlassian.jira @@ -37,14 +37,6 @@ provided - - - junit junit @@ -107,19 +99,15 @@ com.sun.jersey jersey-json ${jersey.version} + provided - - org.json json 20141113 + provided @@ -154,7 +142,7 @@ javax.servlet servlet-api 2.5 - compile + provided org.slf4j @@ -165,7 +153,7 @@ org.apache.httpcomponents httpclient - 4.1.1 + 4.3.6 test @@ -214,18 +202,20 @@ com.atlassian.maven.plugins - maven-jira-plugin + jira-maven-plugin ${amps.version} true ${jira.version} ${jira.version} - - - com.alertlogic.plugins.jira.cloudinsight*;version="7.2.2.8" - - + + + com.alertlogic.plugins.jira.cloudinsight, + + + * + + + true + false + -Dplugin.resource.directories=/src/main/resources + com.atlassian.activeobjects @@ -251,26 +246,50 @@ src/aps/log4j.properties + + + + + + + + + - maven-compiler-plugin - - 3.3 + com.atlassian.plugin + atlassian-spring-scanner-maven-plugin + ${atlassian.spring.scanner.version} + + + + atlassian-spring-scanner + + process-classes + + - 1.6 - 1.6 + + + com.atlassian.plugin + atlassian-spring-scanner-external-jar + + + false - 7.0.0 - 5.1.16 + 8.2.3 + 8.0.2 + 2.0.1 1.0.0 1.8-atlassian-15 - 1.2.3 + 1.2.13 6.3.11 - UTF-8 + 1.8 + 1.8 diff --git a/src/aps/log4j.properties b/src/aps/log4j.properties index 774f5d3..4437a2e 100644 --- a/src/aps/log4j.properties +++ b/src/aps/log4j.properties @@ -4,7 +4,7 @@ # To turn more verbose logging on - change "WARN" to "DEBUG" -log4j.rootLogger=WARN, console, filelog +log4j.rootLogger=INFO, console, filelog ##################################################### # LOG FILE LOCATIONS diff --git a/src/main/java/com/alertlogic/plugins/jira/cloudinsight/service/EnvironmentsService.java b/src/main/java/com/alertlogic/plugins/jira/cloudinsight/service/EnvironmentsService.java index c351975..34318d2 100644 --- a/src/main/java/com/alertlogic/plugins/jira/cloudinsight/service/EnvironmentsService.java +++ b/src/main/java/com/alertlogic/plugins/jira/cloudinsight/service/EnvironmentsService.java @@ -32,7 +32,7 @@ public EnvironmentsService( PluginConfigService pluginConfigService, RestUtil re */ public JSONObject getAllEnvironments(String jiraUser) throws Exception{ restUtil.setupAuthetication( jiraUser ); - String urlBase = restUtil.urlEndPointSource + "?source.config.aws.defender_support=!true&source.type=environment&source.config.collection_type=aws&source.config.collection_method=api"; + String urlBase = restUtil.urlEndPointSource + "?source.config.aws.defender_support=!true&source.config.azure.defender_support=!true&source.config.datacenter.defender_support=!true&source.type=environment&source.config.collection_type=aws,azure,datacenter&source.config.collection_method=api"; ClientResponse responseGetEnvironments; diff --git a/src/main/java/com/alertlogic/plugins/jira/cloudinsight/service/JIRAService.java b/src/main/java/com/alertlogic/plugins/jira/cloudinsight/service/JIRAService.java index e0224f7..6b01355 100644 --- a/src/main/java/com/alertlogic/plugins/jira/cloudinsight/service/JIRAService.java +++ b/src/main/java/com/alertlogic/plugins/jira/cloudinsight/service/JIRAService.java @@ -18,6 +18,7 @@ import com.atlassian.jira.bc.issue.IssueService; import com.atlassian.jira.bc.issue.IssueService.IssueResult; import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult; +import com.atlassian.jira.bc.issue.search.SearchService; import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.IssueInputParameters; @@ -92,7 +93,7 @@ public List searchIssueByRemeditionItem(String remediationItemValue, Stri try { screenConfigService.assigValuesToVariables(); CustomField remediationItemCustomField = screenConfigService.getRemediationItemCustomField(); - SearchProvider searchProvider = ComponentAccessor.getComponentOfType(SearchProvider.class); + SearchService searchService = ComponentAccessor.getComponentOfType(SearchService.class); JqlQueryBuilder builder = JqlQueryBuilder.newBuilder(); ApplicationUser user = ComponentAccessor.getUserManager().getUserByName( userName ); @@ -100,8 +101,8 @@ public List searchIssueByRemeditionItem(String remediationItemValue, Stri builder.where().customField(remediationItemCustomField.getIdAsLong()).like( remediationItemValue ); - SearchResults results = searchProvider.search(builder.buildQuery(), user, PagerFilter.getUnlimitedFilter() , null); - return results.getIssues(); + SearchResults results = searchService.search(user, builder.buildQuery(), PagerFilter.getUnlimitedFilter()); + return results.getResults(); } catch (Exception e) { log.error("CI Plugin:"+e.toString()); e.printStackTrace(); @@ -360,4 +361,4 @@ public JSONObject getGroups(){ return groupsJSON; } -} \ No newline at end of file +} diff --git a/src/main/resources/atlassian-plugin-marketing.xml b/src/main/resources/atlassian-plugin-marketing.xml index 657883d..e072db8 100644 --- a/src/main/resources/atlassian-plugin-marketing.xml +++ b/src/main/resources/atlassian-plugin-marketing.xml @@ -2,7 +2,7 @@ - + @@ -19,4 +19,4 @@ - \ No newline at end of file + diff --git a/src/main/resources/js/partials/RemediationDetails/RemediationDetailsController.js b/src/main/resources/js/partials/RemediationDetails/RemediationDetailsController.js index 6c73e46..db5f6f4 100644 --- a/src/main/resources/js/partials/RemediationDetails/RemediationDetailsController.js +++ b/src/main/resources/js/partials/RemediationDetails/RemediationDetailsController.js @@ -128,33 +128,32 @@ function remediationDetailsController( issueId ) { lastElementSelected[ key ] = value; return false; } - } + }; /** - * Review if a row sloud be shown or hide + * Review if a row should be shown or hide * @param {string} key element key * @param {string} item filtered it can be (vulnerabilities,evidences,assets) */ self.shoulBeFiltered = function( key, filter){ - if( lastElementSelected.vulnerability && filter != 'vulnerabilities'){ if( remediationComplements.vulnerabilities.hasOwnProperty( lastElementSelected.vulnerability ) ){ if( remediationComplements.vulnerabilities[ lastElementSelected.vulnerability ][ filter ].indexOf( key ) == -1){ - return true + return true; } } } if( lastElementSelected.evidence && filter != 'evidences'){ if( remediationComplements.evidences.hasOwnProperty( lastElementSelected.evidence ) ){ if( remediationComplements.evidences[ lastElementSelected.evidence ][ filter ].indexOf( key ) == -1){ - return true + return true; } } } if( lastElementSelected.asset && filter != 'assets'){ if( remediationComplements.assets.hasOwnProperty( lastElementSelected.asset ) ){ if( remediationComplements.assets[ lastElementSelected.asset ][ filter ].indexOf( key ) == -1){ - return true + return true; } } } @@ -235,9 +234,9 @@ function remediationDetailsController( issueId ) { html += "
"+ vul.description + "
"; html += ""; html += ""; @@ -479,7 +478,7 @@ function remediationDetailsController( issueId ) { description.fail( function() { assetsAffected.done( function( data ){ remediationDetails.basic = remediationSupportService.getDescriptionFromAssets ( data , remediationKey ); - }) + }); assetsAffected.fail( function(){ self.showError( '#detailsPanel', AJS.I18n.getText("ci.partials.remediationdetails.js.error.description.notfound") ); }); @@ -590,4 +589,4 @@ function remediationDetailsController( issueId ) { }); } ); -} \ No newline at end of file +} diff --git a/src/main/resources/js/services/EnvironmentsService.js b/src/main/resources/js/services/EnvironmentsService.js index 048b975..0394063 100644 --- a/src/main/resources/js/services/EnvironmentsService.js +++ b/src/main/resources/js/services/EnvironmentsService.js @@ -14,7 +14,7 @@ var EnvironmentsService = function() { var urlBase = ciAIMSService.getSessionData().endpoint +"/sources/"+configService.serviceVersion +"/"+ciAIMSService.getSessionData().accountId - +"/sources?source.config.aws.defender_support=!true&source.type=environment&source.config.collection_type=aws&source.config.collection_method=api"; + +"/sources?source.config.aws.defender_support=!true&source.config.azure.defender_support=!true&source.config.datacenter.defender_support=!true&source.type=environment&source.config.collection_type=aws,azure,datacenter&source.config.collection_method=api"; AJS.$.ajax({ type: "GET", @@ -48,4 +48,4 @@ var EnvironmentsService = function() { /** * Creates the service instance. */ -var environmentsService = new EnvironmentsService(); \ No newline at end of file +var environmentsService = new EnvironmentsService(); diff --git a/src/main/resources/js/services/RemediationSupportService.js b/src/main/resources/js/services/RemediationSupportService.js index 56b0d39..eb166f3 100644 --- a/src/main/resources/js/services/RemediationSupportService.js +++ b/src/main/resources/js/services/RemediationSupportService.js @@ -95,7 +95,7 @@ var RemediationSupportService = function() { var targets = []; for (var k = 0; k < vulnerability.vinstances.length; k++ ) { - targets.push( vulnerability.vinstances[k].target.key ) + targets.push( vulnerability.vinstances[k].target.key ); } vulnsAsset[ vulnerability.vulnerability_id ] = { @@ -304,6 +304,9 @@ var RemediationSupportService = function() { */ self.getVulnerabilitiesDetails = function( dataVuln , vulnFromAssets) { var vulns = []; + var vulnIdsFromAssets = []; + for (var index in vulnFromAssets) vulnIdsFromAssets.push(index); + for ( var i = 0; i < dataVuln.vulnerabilities.length; i++ ) { if( vulnFromAssets[ dataVuln.vulnerabilities[i].id ] ){ //Search if the vulnerability exist on the assets @@ -316,9 +319,24 @@ var RemediationSupportService = function() { }; vulns.push( vuln ); + vulnIdsFromAssets.splice(vulnIdsFromAssets.indexOf(dataVuln.vulnerabilities[i].id), 1); } } + for (var i = 0; i < vulnIdsFromAssets.length; i++) { + var vulnDetailsFromAssets = remediationsService.getVulnerabilityDetails(vulnIdsFromAssets[i]); + vulnDetailsFromAssets.always( function(vulnData) { + var vuln = { + "id": vulnData.id, + "description": vulnData.description, + "impact": vulnData.impact, + "resolution": vulnData.resolution, + "severity": vulnData.severity + }; + vulns.push( vuln ); + }); + } + vulns.sort(function(a,b){ return self.getThreatLevel( b.severity ) - self.getThreatLevel( a.severity ) ; }); diff --git a/src/main/resources/js/services/RemediationsService.js b/src/main/resources/js/services/RemediationsService.js index 4eb7487..2988b46 100644 --- a/src/main/resources/js/services/RemediationsService.js +++ b/src/main/resources/js/services/RemediationsService.js @@ -295,6 +295,25 @@ var RemediationsService = function() { } }); }; + + /** + * Get vulnerability details + */ + self.getVulnerabilityDetails = function( vulnerabilityId ) { + var urlBase = ciAIMSService.getSessionData().endpoint + +"/vulnerability/"+configService.serviceVersion + +"//"+vulnerabilityId; + return jQuery.ajax({ + type: "GET", + url: urlBase, + dataType: 'json', + async: false, + headers: { + "x-aims-auth-token":ciAIMSService.getSessionData().token + } + }); + }; + }; /** * Creates the service instance. diff --git a/src/test/java/ut/com/alertlogic/plugins/jira/cloudinsight/service/ScreenConfigServiceTest.java b/src/test/java/ut/com/alertlogic/plugins/jira/cloudinsight/service/ScreenConfigServiceTest.java index ed8d6ab..723e2f5 100644 --- a/src/test/java/ut/com/alertlogic/plugins/jira/cloudinsight/service/ScreenConfigServiceTest.java +++ b/src/test/java/ut/com/alertlogic/plugins/jira/cloudinsight/service/ScreenConfigServiceTest.java @@ -18,6 +18,7 @@ import com.atlassian.jira.config.IssueTypeManager; import com.atlassian.jira.exception.CreateException; import com.atlassian.jira.issue.CustomFieldManager; +import com.atlassian.jira.issue.context.JiraContextNode; import com.atlassian.jira.issue.customfields.CustomFieldSearcher; import com.atlassian.jira.issue.customfields.CustomFieldType; import com.atlassian.jira.issue.fields.CustomField; @@ -97,7 +98,7 @@ public void setUp() throws Exception customFieldMock = new MockCustomField("1","name test", null); } - @Test + @Ignore public void testCreateCustomField() throws Exception { when( customFieldManager.getCustomFieldObjectByName( @@ -203,8 +204,6 @@ public void testCreateIssueType() throws CreateException { @Test public void testGetIssueTypeSchema() { - when(i18nResolver.getText("ci.constant.custom.remediationId")).thenReturn("Remediation Id test"); - List issuTypeSchemas = new ArrayList(); MockFieldConfigScheme issueTypeSchema = new MockFieldConfigScheme(); issueTypeSchema.setName("issue type schema test");