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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @bhushannerkar I don't have background on this but let me add a fee more experts

@Sandeep Rajput  @Community Alums  @Mark Manders 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

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

Hello Ankur,

Thanks for the information! Could you please share more details on how to implement this custom solution? Any recommended JAR files for the MID Server or JavaScript libraries for UI scripts would be really helpful.

@bhushannerkar 

I had used this to generate a password protected zip so see if the same supports to detect if file is password protected or not

zip4j-2.11.2

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