Filenames with slashes not updating

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Filenames with slashes not updating

Greetings,


So I have been pulling rasterized images with the names of the URLs attached into XSOAR and attempting to pipe them into some ServiceNow tickets, but character restrictions are giving the system issues on what files to call during the upload process.  

The files are stored as the proper URL context, but filenames cannot have slashes in them, so the file names are being edited with underscores in place of the slashes when the files are generated or when you attempt to download said file, but in XSOAR it still thinks of the file as being named with proper URL context including the slashes, so when I go to upload them in other tasks the files are not found.  

I have attempted to replace characters via conditional tasks after the images are generated but the system is limiting me on what contexts I can use to identify them, and I can't seem to pull anything in to transform.  

Any ideas?

MicrosoftTeams-image (3).png

 

MicrosoftTeams-image (4).png

 

MicrosoftTeams-image (5).png

 

1 accepted solution

Accepted Solutions

Hey @asawyer,

So I finally got it to work.  By moving the re-naming steps into the rasterize process instead of the SN upload process they are finally posing into the ticket with the the full names.

Thanks for all of your help!

View solution in original post

10 REPLIES 10

L3 Networker

Hi @Jersey_Mankowski,

 

It looks like you are passing in the URL to the `file_name` input to `rasterize`. The default filename for the `rasterize` result is simply "url.png". Could you try leaving the `file_name` input blank or passing in a different value instead of the URL?

Hey @asawyer 

The plan is to get the url address in the filename so that when It gets move around or exported to tickets you can tell where the image was from.

Rasterize is working fine with default naming.

L3 Networker

Hey @Jersey_Mankowski – Ah, I'm tracking now. There are a couple of complications here. The first is the replacement of certain characters, as you mentioned in your original post, and the other is a restriction on filename length (on both the XSOAR and ServiceNow side).

 

The see what XSOAR changed the filename to, download the result of rasterize and view the filename.

 

From my testing, the maximum filename length for ServiceNow is 255 characters. So to pass in a valid file_name arg value to servicenow-upload-file:

1. Replace at least the slashes with underscores, so the value is not misinterpreted as a URL (Replace transformer)

 

2. Truncate the value to 251 characters max to leave room for the file extension – You can do this using the RegexGroups transformer with regex:  ^(.{,251})

3. Concat the ".png" file extension

 

Please give that a try and let us know if it works!

 

Screen Shot 2022-05-26 at 3.25.43 PM.png

Hey @asawyer 

I like what you are thinking, and that could be half of it, but with the new transforms I have been seeing an error in the RE.py lib, and some other errors with the replace, I did get it to go through as expected but it's still failing to upload the file and says it does not exist, even when looking up by artifact. 

For reference I am doing the file_name transformations in the !servicenow-upload-file task.  I have also tried a replace on the slashes to underscore directly after the rasterize, but it would never find anything.    I feel like the automatic file renaming by the system is getting these images corrupted or lost somehow, but it's hard to confirm that when I can go download the artifacts. 

 2022-05-27 09_17_31-#116024 [Phish Alert] FW_ [EXTERNAL] Invoice from Qene’s Catering - Work Plan.png2022-05-27 09_41_30-#116024 [Phish Alert] FW_ [EXTERNAL] Invoice from Qene’s Catering - Work Plan.png2022-05-27 10_25_46-#116017 [Phish Alert] FW_ [EXTERNAL] Fitness Center Owners Can Now Claim ERTC Re.png

Hey @Jersey_Mankowski – Re: your third screenshot, I get the same error if I don't pass in the file_name arg. 

 

For the example from your last post, could you share the following so we can troubleshoot further?:

1. Screenshots of the exact values and transformers you are using to create the file_name arg, that are leading to the transformer (replace and regex) errors

2. Filename of the rasterize output file when you download it onto your local filesystem

So the regex errors are only happening occasionally.  Also, I added the 'underscore to hyphen' transform after just having the 'slash to underscore' transform to try and double up and maybe get the system to realize the renaming function since it always seems to look for the file name with the slashes in it and fails the upload when it can't find the file.  I also tried it only with the slash transform and was seeing the same results.


2022-05-27 10_25_46-#116017 [Phish Alert] FW_ [EXTERNAL] Fitness Center Owners Can Now Claim ERTC Re.png2022-06-02 07_58_34-Playbooks.png2022-06-02 08_04_06-#116017 [Phish Alert] FW_ [EXTERNAL] Fitness Center Owners Can Now Claim ERTC Re.png2022-06-02 08_04_25-https___ercfundstoday.com.png ‎- Photos.png

Hi @Jersey_Mankowski – In your first screenshot with the error, the file_name arg was not passed. From my testing, that arg must be passed in order for the servicenow-upload-file command to succeed. Could you try running the command again with the file_name arg?

I am not sure I understand.  The second image shows the file_name arguments, also the upload task is looking for the file based on the filename.  

What am I missing?

The second image shows the file_name arg, but the first does not, indicating no file_name arg was actually passed to that command in that first screenshot.

 

I replicated your example and the following worked for me:

 

First, I saved the URL to context key url using the Set command: 

 

Screen Shot 2022-06-15 at 1.21.44 PM.png

 

Screen Shot 2022-06-15 at 1.21.37 PM.png

 

Then I ran the servicenow-upload-file command, applying the transformers discussed above to the file_name arg value, as shown in the screenshots below:

!servicenow-upload-file id=<SERVICENOW_SYS_ID> file_id=<FILE_ENTRY_ID> file_name=<URL_WITH_TRANSFORMERS> using=<SERVICENOW_INSTANCE_NAME>

 

Screen Shot 2022-06-15 at 1.22.38 PM.png

 

Screen Shot 2022-06-15 at 1.24.02 PM.png

 

Screen Shot 2022-06-15 at 1.24.41 PM.png

 

Please give that a try and let me know if that works for you.

Hey @asawyer,

So I finally got it to work.  By moving the re-naming steps into the rasterize process instead of the SN upload process they are finally posing into the ticket with the the full names.

Thanks for all of your help!

  • 1 accepted solution
  • 4561 Views
  • 10 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!