How to check if Uploaded 7zip File is Encrypted in ServiceNow

bhushannerkar
Tera Expert

Hello Everyone,

I need to implement a backend validation in ServiceNow to check if an uploaded 7zip (.7z) file is password-protected or encrypted. The requirement is:

  1. When a 7zip file is uploaded as an attachment (e.g., in sys_attachment), we need to determine if it is encrypted.
  2. If the file is not encrypted, it should be removed automatically.
  3. This check needs to happen entirely from the backend (Server-side).

I’m looking for suggestions on:
How to detect encryption in a 7zip file from ServiceNow’s backend.
Any possible use of Glide APIs, Script Includes, or other ServiceNow features.
Whether ServiceNow has any built-in utilities for file parsing like it does for Excel (e.g., GlideExcelParser).

Has anyone implemented something similar or knows an approach to achieve this? Any help would be appreciated!

Thanks in advance! 

attachment_upload.PNGattachment_added.PNG

CC: @Ankur Bawiskar @Dr Atul G- LNG  @Ravi Gaurav @Pradeep Sharma @Chuck Tomasi@Brad Bowman

 

Thanks
Bhushan 

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@bhushannerkar 

Nothing is present OOB to check if file is password-protected or encrypted.

You will have to use custom solution by using mid server and external jar files to determine this.

OR

may be some javascript library which can be used via UI script

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

Hello @Ankur Bawiskar ,

For MID Server ZIP Password Protection Validation, 

I have successfully completed the following setup:

  1. Installed and validated MID Server, with 7-Zip installed at "C:\Program Files\7-Zip\7z.exe".

  2. Created a PowerShell script in MID Server Scripts module to download attachment by sys_id, validate password protection, and send results back via ECC Queue.

  3. Built a Business Rule on sys_attachment (after insert) to trigger ECC Queue and run the MID Server script.

  4. Built a Business Rule on ecc_queue (after insert) to parse the MID Server response, update attachment/incident records, delete unprotected files, and toggle the "custom_field" field.

  5. Added the "custom_field" Boolean field on the parent table (e.g., Incident) with an onChange Client Script to reload the form after processing.

View solution in original post

7 REPLIES 7

Hello @Ankur Bawiskar ,

For MID Server ZIP Password Protection Validation, 

I have successfully completed the following setup:

  1. Installed and validated MID Server, with 7-Zip installed at "C:\Program Files\7-Zip\7z.exe".

  2. Created a PowerShell script in MID Server Scripts module to download attachment by sys_id, validate password protection, and send results back via ECC Queue.

  3. Built a Business Rule on sys_attachment (after insert) to trigger ECC Queue and run the MID Server script.

  4. Built a Business Rule on ecc_queue (after insert) to parse the MID Server response, update attachment/incident records, delete unprotected files, and toggle the "custom_field" field.

  5. Added the "custom_field" Boolean field on the parent table (e.g., Incident) with an onChange Client Script to reload the form after processing.

@bhushannerkar 

it would be nice if you could share the scripts etc so that it helps other members as well

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Sandeep Rajput
Tera Patron
Tera Patron

@bhushannerkar There is no OOTB way to verify if the uploaded attachment is encrypted or not.