cancel
Showing results for 
Search instead for 
Did you mean: 
Create a Post
Highlighted
Tom_Cripps
Silver

Finding a URL in all custom Application/Sites rather than just one

Hi,

I have a script currently utilising the mgmt api to open a specific application/site and show all the URL's listed. I then can then grep a saved output to find a single URL. I look to add filtering built into the script but has anyone had any experience with looping over all application/sites to find a single URL?

Tom

5 Replies
Admin
Admin

Re: Finding a URL in all custom Application/Sites rather than just one

I assume at a high level, it something like:
1. List out the custom applications using show application-sites
2. For each application listed, run the code you've already written.
Tom_Cripps
Silver

Re: Finding a URL in all custom Application/Sites rather than just one

Makes sense in theory. Will wait to see if anyone else has any feedback.

Tom_Cripps
Silver

Re: Finding a URL in all custom Application/Sites rather than just one

Hi Daemon,

Looking at this, show application-site appears to show too much or doesn't allow me to look at Custom app/sites we've already made.

Anyone in the community you know who could assist?

Thanks Tom

0 Kudos
Maik
Silver

Re: Finding a URL in all custom Application/Sites rather than just one

Not sure if I understand you correctly, but once you have created a custom application/site you can search for it via the "show application-site" command - you just need to have the name, uid or application id of the related object. So if you have the name and it is called "CustomTest" you an use the following command to receive your required Information; the contained URLs:

> show application-site name "CustomTest" --format json
{
  "uid" : "e43c6931-8810-482c-836a-ffc5a2a2750a",
  "name" : "CustomTest",
  "type" : "application-site",
  "domain" : {
    "uid" : "41e821a0-3720-11e3-aa6e-0800200c9fde",
    "name" : "SMC User",
    "domain-type" : "domain"
  },
  "application-id" : 0,
  "primary-category" : "Custom_Application_Site",
  "description" : "",
  "risk" : "Medium",
  "user-defined" : true,
  "url-list" : [ "www.test.org", "www.test.com", "test.biz" ],
  "urls-defined-as-regular-expression" : false,
  "groups" : [ ],
  "comments" : "",
  "color" : "black",
  "icon" : "Objects/application",
  "tags" : [ ],
  "meta-info" : {
    "lock" : "locked by current session",
    "validation-state" : "ok",
    "last-modify-time" : {
      "posix" : 1575322111151,
      "iso-8601" : "2019-12-02T21:28+0000"
    },
    "last-modifier" : "admin",
    "creation-time" : {
      "posix" : 1575322111151,
      "iso-8601" : "2019-12-02T21:28+0000"
    },
    "creator" : "admin"
  },
  "read-only" : false
}
 
If you want a list of all the custom application site objects that you have created you need to execute the command/query the api via "show application-sites" - this will return all related objects. Note; per default it returns 50 per call, this can be increased but should not exceed more than 200-300 per api call - in the best case you keep it at 50. In order to receive all objects you need to call this command over and over again and increase the related Offset parameters. More can be read in the API documentation. In parallel to that you also need to make sure to "take note" of all objects that have the primary-category of "Custom_Application_Site", aka all obejcts that were created manually. To achieve this you can simply write down their related uid in a list, that can later be iterated over with the show application-site command.
 
for identifier in customApplSiteUID_list
    do "show application-site uid identifier"
 
[Of course this is not real code, but it should give you an idea what needs to be done.]
 
Afterwards you have the output from above for all the required sites. Now you only need to take each of These Outputs and write the URLs into a list, which can be used for your searching purposes.
0 Kudos
Tom_Cripps
Silver

Re: Finding a URL in all custom Application/Sites rather than just one

Hi Maik,

Thanks for that. The second option is more inline with what i'm trying to achieve. My issue though, is identifying what is custom and what is not without having the ability to search against the primary category in the api call. I'll have to see if there is some other way of doing it without looking at the uid as this requires manually updating of the uid. 

Thanks for the insight.

Tom

0 Kudos