Azure-Sentinel icon indicating copy to clipboard operation
Azure-Sentinel copied to clipboard

Fortinet-GetEntityDetails not authenticating against Fortigate

Open scottbrien01 opened this issue 5 years ago • 19 comments

Describe the bug Receive error "Unexpected character encountered while parsing value: <. Path '', line 0, position 0." when running function app Fortinet-GetEntityDetails

To Reproduce Steps to reproduce the behavior:

  1. Assign Fortinet-FortiGate-ResponseOnIP playbook to analytics rule
  2. Trigger rule so that logic app fires
  3. Logic app will get to "check address object is already in firewall" and will hang.
  4. Check function app monitor to confirm that API is calling Fortinet-GetEntityDetails and that error is generated

Expected behavior API should run through so that logic app can complete.

Screenshots image

scottbrien01 avatar Aug 19 '21 04:08 scottbrien01

Thank you for submitting an Issue to the Azure Sentinel GitHub repo! You should expect an initial response to your Issue from the team within 5 business days. Note that this response may be delayed during holiday periods. For urgent, production-affecting issues please raise a support ticket via the Azure Portal.

github-actions[bot] avatar Aug 19 '21 04:08 github-actions[bot]

Issue is due to the access_code not being appended to the request to the fortigate and reply has the following when unauthorised.

< ! DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN ">

scottbrien01 avatar Aug 19 '21 23:08 scottbrien01

Thank you for submitting an Issue to the Azure Sentinel GitHub repo! You should expect an initial response to your Issue from the team within 5 business days. Note that this response may be delayed during holiday periods. For urgent, production-affecting issues please raise a support ticket via the Azure Portal.

github-actions[bot] avatar Aug 23 '21 01:08 github-actions[bot]

Thank you for submitting an Issue to the Azure Sentinel GitHub repo! You should expect an initial response to your Issue from the team within 5 business days. Note that this response may be delayed during holiday periods. For urgent, production-affecting issues please raise a support ticket via the Azure Portal.

github-actions[bot] avatar Aug 26 '21 17:08 github-actions[bot]

Thank you for submitting an Issue to the Azure Sentinel GitHub repo! You should expect an initial response to your Issue from the team within 5 business days. Note that this response may be delayed during holiday periods. For urgent, production-affecting issues please raise a support ticket via the Azure Portal.

github-actions[bot] avatar Aug 26 '21 17:08 github-actions[bot]

I believe this issue has something to do with the keyvault/managed user identity. I have gotten this function to work by appending the &access_token=[access token] to the line of code here

var httpRequest = new HttpRequestMessage(HttpMethod.Get, new Uri(endpointURL + baseURL + entity + "?" + filter + "&access_token=[accesstoken]"));

and removing the following lines from the function. var key = Environment.GetEnvironmentVariable("Authorization", EnvironmentVariableTarget.Process); httpRequest.Headers.Add("Authorization", key.ToString());

Not sure where the error is occurring though

scottbrien01 avatar Aug 26 '21 23:08 scottbrien01

Hi, Wanted to check in to see if there were any thoughts on this one?

scottbrien01 avatar Sep 01 '21 00:09 scottbrien01

Thank you for submitting an Issue to the Azure Sentinel GitHub repo! You should expect an initial response to your Issue from the team within 5 business days. Note that this response may be delayed during holiday periods. For urgent, production-affecting issues please raise a support ticket via the Azure Portal.

github-actions[bot] avatar Sep 01 '21 07:09 github-actions[bot]

@lior-tamir : This looks to be related to Playbooks, can you please take a look.. Thanks !!!

v-rucdu avatar Sep 01 '21 07:09 v-rucdu

Hi, Wanted to check in to see if there was anything we could look at on this one?

scottbrien01 avatar Sep 10 '21 04:09 scottbrien01

We are working on this one and will update once we have solution.

ashishsyal avatar Oct 18 '21 10:10 ashishsyal

Hi @scottbrien01 Apologies for delay in responding. I have tried to reproduce the error but, we are not able to reproduce this. Can you please help us by checking below points

Have you authorized this function app to access key vault resource ?

Can you try printing "key" and "httpRequest" value and see whether we have "key" appearing in httpRequest

  • log.LogInformation(key);
  • log.LogInformation(httpRequest.ToString()); - Try printing after appending the "key" to the request Log is appearing like below - image

anki-narravula avatar Oct 20 '21 08:10 anki-narravula

Hi Anki,

We resolved this issue internally, the issue is with the authorization key. since it is being included in the http header you need to include the codeword bearer: "api key". so instead of just entering the API key in the keyvault you need to put "bearer: "api key""

I think it would be best to automatically include the bearer: so users can simply put the API key in the key vault.

From Fortinet development site: image

Cheers, Scott

scottbrien01 avatar Oct 20 '21 11:10 scottbrien01

Hi Scott,

Thank you for the update. Really appreciate it. We will update the code accordingly.

Thanks, Anki

anki-narravula avatar Oct 21 '21 05:10 anki-narravula

Thank you for submitting an Issue to the Azure Sentinel GitHub repo! You should expect an initial response to your Issue from the team within 5 business days. Note that this response may be delayed during holiday periods. For urgent, production-affecting issues please raise a support ticket via the Azure Portal.

github-actions[bot] avatar Oct 25 '21 10:10 github-actions[bot]

Hi @scottbrien01 this bug is addressed now. Shall we close this issue ?

anki-narravula avatar Nov 10 '21 10:11 anki-narravula

We will close this issue, please reopen incase you still face any issues... Thanks!!!

v-rucdu avatar Nov 18 '21 05:11 v-rucdu

Thank you for submitting an Issue to the Azure Sentinel GitHub repo! You should expect an initial response to your Issue from the team within 5 business days. Note that this response may be delayed during holiday periods. For urgent, production-affecting issues please raise a support ticket via the Azure Portal.

github-actions[bot] avatar Nov 18 '21 05:11 github-actions[bot]

Hello,

I hope you are well :)

Please when I run this function , I received this error : The remote certificate is invalid according to the validation procedure.

What do you think ?

Thanks in advance

NinaSec avatar Mar 07 '23 13:03 NinaSec