Skip to content

Commit

Permalink
Enable Core REST API with general XSIAM endpoints (#31226)
Browse files Browse the repository at this point in the history
* mostly works

* added release notes

* fixes from review
  • Loading branch information
DinaMeylakh authored Nov 30, 2023
1 parent 9506ddb commit d89f729
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
24 changes: 8 additions & 16 deletions Packs/DemistoRESTAPI/Integrations/CoreRESTAPI/CoreRESTAPI.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@

const MIN_HOSTED_XSOAR_VERSION = '8.0.0';
// list was taken from https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR-8-API
const SYSTEM_ENDPOINTS = [
"/public_api/v1/audits/management_logs",
"/public_api/v1/rbac/get_roles",
"/public_api/v1/rbac/get_user_group",
"/public_api/v1/rbac/get_users",
"/public_api/v1/rbac/set_user_role"
]

var serverURL = params.url;
if (serverURL.slice(-1) === '/') {
Expand All @@ -24,14 +16,6 @@ isHosted = function () {
return false
}

// only when using XSIAM or XSOAR >= 8.0 we will add the /xsoar suffix
// and only when it is not a system endpoint (note: this list does not include all system endpoints!)
if (isHosted()) {
if ((!serverURL.endsWith('/xsoar')) && (!SYSTEM_ENDPOINTS.includes(args.uri))) {
serverURL = serverURL + '/xsoar'
}
}

var marketplace_url = params.marketplace_url? params.marketplace_url : 'https://marketplace.xsoar.paloaltonetworks.com/'

getTenantAccountName = function () {
Expand Down Expand Up @@ -79,6 +63,14 @@ getAdvancedAuthMethodHeaders = function(key, auth_id, content_type,) {

getRequestURL = function (uri) {
var requestUrl = serverURL;

// only when using XSIAM or XSOAR >= 8.0 we will add the /xsoar suffix
// and only when it is not a /public_api endpoint.
if (isHosted()) {
if ((!serverURL.endsWith('/xsoar')) && (!uri.startsWith('/public_api'))) {
requestUrl += '/xsoar'
}
}
if (params.use_tenant){
requestUrl += '/' + getTenantAccountName();
}
Expand Down
6 changes: 6 additions & 0 deletions Packs/DemistoRESTAPI/ReleaseNotes/1_3_39.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### Core REST API

- Added support for XSIAM api endpoints.
2 changes: 1 addition & 1 deletion Packs/DemistoRESTAPI/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Cortex REST API",
"description": "Use Demisto REST APIs",
"support": "xsoar",
"currentVersion": "1.3.38",
"currentVersion": "1.3.39",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit d89f729

Please sign in to comment.