Hi Itzik,
Not at all - that's what this forum if for! :D
Hopefully the missing import statement is all that it was, but let's wait and see.
So you can't create custom fields "on-the-fly" in a script in the way I think you're describing, but you can define them via the UI as described by [
this link] ahead of time before you run the script.
So let's say you create a new custom field called
is_private_ip
, you could populate that from the script like so:
incident.properties.is_private_ip = is_ip_private("<ip address>")
------------------------------
PAUL CURRAN
------------------------------
Original Message:
Sent: Tue July 23, 2019 01:49 PM
From: Itzik Shviro
Subject: Script to check ip address
Oppps... no i didnt. i will try to add "import re" tomorrow.
Also, lets say the script answer is "not none"(private ip), how can i push the answer to a new custom field in the same resilient incident?
Sorry for being such a noob :)
------------------------------
Itzik Shviro
Original Message:
Sent: Tue July 23, 2019 01:05 PM
From: PAUL CURRAN
Subject: Script to check ip address
Hi Itzik,
Good stuff! :)
Hmm... I see, it might might be best to post your script here then in that case?
Did you import the re
module at the top of your script?
------------------------------
PAUL CURRAN
Original Message:
Sent: Tue July 23, 2019 12:39 PM
From: Itzik Shviro
Subject: Script to check ip address
Hi paul,
Thanks a lot.
You did interpret it correctly. exactly what i was looking for.
As for the first part, the error i get - "No viable alternative at input" (line 1)
------------------------------
Itzik Shviro
Original Message:
Sent: Tue July 23, 2019 11:40 AM
From: PAUL CURRAN
Subject: Script to check ip address
Hi Itzik,
So what error did you get? Can you provide the output?
To assign the result to a field you would simply do something like:
incident.<field> = is_ip_private("<ip address>")
or in the case of a custom field
incident.properties.<custom_field> = is_ip_private("<ip address>")
(did I interpret that last part of the question correctly?)
------------------------------
PAUL CURRAN
Original Message:
Sent: Tue July 23, 2019 11:32 AM
From: Itzik Shviro
Subject: Script to check ip address
Hi paul,
I have already tried the exact same script and got an error.
Also, how can i add the result to a field value?
------------------------------
Itzik Shviro
Original Message:
Sent: Tue July 23, 2019 09:01 AM
From: Itzik Shviro
Subject: Script to check ip address
Hi,
As part of my workflow, i want to determine if an ip address(from an existing field) is public or private via python script, and than update another field with the response.
I know there is a built in function for that in python.
For example:
>>> import ipaddress
>>> ipaddress.ip_address('192.168.0.1').is_private
True
The problem is that i am not sure how to implement it in resilient.
Any help would be appreciated.
------------------------------
Itzik Shviro
------------------------------