cancel
Showing results for 
Search instead for 
Did you mean: 

Rules script to search for 2 pieces of information and if found ok else block

SOLVED
yo_kobus
New Contributor

Rules script to search for 2 pieces of information and if found ok else block

Good Morning all

I have been searching in the docs and tried many things for a considerable amount ot time, but I do need help now.

we have the following url:

http://api.mycompany.com/web/impex/usageProfileExportAPI?contentProviderId=1234&usageProfileId=1234&fileFormat=JSON&ss.exp=20221022151011&ss.sig=9zz1b2e8f75004

I am trying to setup a rule that

if usageProfileExportAPI and usageProfileId is present in the url

then send the traffic to a pool

if it is not present

then send it to a black hole

I have tried:

$AllowExportAPI = http.getPath();
if( string.contains( $AllowExportAPI, "usageProfileExportAPI" ) ) {
if( string.contains( $AllowExportAPI, "usageProfileId" ) ) {
pool.use( "STG api.stg 10090" );
} else {
http.redirect( "https://www.mycompany.com" );
}
} else {
pool.use( "STG api.stg 10090" );
}

and

$AllowExportAPI = http.getPath();
if( string.contains( $AllowExportAPI, "usageProfileExportAPI" ) ) {
   $AllowUsageProfile = http.getPath();
   if( string.contains( $AllowUsageProfile, "usageProfileId" ) ) {
      pool.use( "STG api.stg 10090" );
   } else {
      http.redirect( "https://www.mycompany.com" );
   }
} else {
   pool.use( "STG api.stg 10090" );
}

and

$AllowExportAPI = http.getPath();
if( string.contains( $AllowExportAPI, "usageProfileExportAPI" ) ) {
   $AllowUsageProfile = http.getPath();
   if( string.contains( $AllowUsageProfile, "usageProfileId" ) ) {
      http.redirect( "https://www.mycompany.com" );
   } else {
      pool.use( "STG api.stg 10090" );
   }
} else {
   pool.use( "STG api.stg 10090" );
}

and

$AllowExportAPI = http.getPath();
if( string.contains( $AllowExportAPI, "usageProfileExportAPI" ) && string.contains( $AllowExportAPI, "usageProfileId" ) ) {
   http.redirect( "https://www.mycompany.com/" );
} else {
   pool.use( "STG api.stg 10090" );
}

and

$AllowExportAPI = http.getPath();
if( string.contains( $AllowExportAPI, "usageProfileExportAPI" ) & string.contains( $AllowExportAPI, "usageProfileId" ) ) {
   http.redirect( "https://www.mycompany.com/" );
} else {
   pool.use( "STG api.stg 10090" );
}

and lastly:

$AllowExportAPI = http.getPath();
if( string.contains( $AllowExportAPI, "usageProfileExportAPI" ))
{
   http.redirect( "https://www.mycompany.com/" );
} else {
   pool.use( "STG api.stg 10090" );
}
if (!string.contains( $AllowExportAPI, "usageProfileId" ))
{
  http.redirect( "https://www.mycompany.com/" );
}

None of these worked so for now I am using:

$AllowExportAPI = http.getPath();
if( string.contains( $AllowExportAPI, "usageProfileExportAPI" ) ) {
   http.redirect( "https://www.mycompany.com/" );
}

until I can get this sorted.

Can anybody please help with this?

Thank you

Kobus

1 ACCEPTED SOLUTION

Accepted Solutions
yo_kobus
New Contributor

Re: Rules script to search for 2 pieces of information and if found ok else block

Thank you. I will test thos and get back to you.

Kobus

View solution in original post

4 REPLIES 4
yo_kobus
New Contributor

Re: Rules script to search for 2 pieces of information and if found ok else block

I have also tried this:

$AllowExportAPI = http.getPath();

$usageProfileExportAPI = string.contains( $AllowExportAPI, "usageProfileExportAPI" );
$usageProfileId = string.contains( $AllowExportAPI, "usageProfileId" );

if( $usageProfileExportAPI == 1 & $usageProfileId == 1 ) {
   pool.use( "STG cds1.stg 10090" );
} else {
   http.redirect( "https://www.yospace.com/" );
}
pwallace
Community Manager

Re: Rules script to search for 2 pieces of information and if found ok else block

Hello, it looks like you want to look for "usageProfileExportAPI" in the URL path, and for "usageProfileId" in the query string, following the URL?

 

So something like this might work:

 

# What is the client asking for?
$path = http.getPath();

# ... and the QueryString
$query = http.getQueryString();

# Test each part separately
if( string.contains( $path, "usageProfileExportAPI" ) ) {
   if( string.contains( $query, "usageProfileId" ) ) {
      ...
   }
}

Couple of useful docs:

https://community.pulsesecure.net/t5/Pulse-Secure-vADC/Evaluating-and-Prioritizing-Traffic-with-Traf...

 

https://community.pulsesecure.net/t5/Pulse-Secure-vADC/HowTo-Inspect-HTTP-request-parameters/ta-p/28...

 

pwallace
Community Manager

Re: Rules script to search for 2 pieces of information and if found ok else block

I will also move this post to the Pulse vADC forum

 

yo_kobus
New Contributor

Re: Rules script to search for 2 pieces of information and if found ok else block

Thank you. I will test thos and get back to you.

Kobus