This application automates the process of injecting traceability and audit logging into an existing Ignition project. It scans the source project for specific functions (such as tag reads/writes and database queries), injects auditing wrappers around those calls, and outputs the modified files to a new destination folder.
All modifications made during this process are logged to a SQLite database, ensuring full traceability of what was changed and preserving the original code.
Note: This application is configured to work exclusively with Perspective components and project-level Python scripts. It does not process or modify Vision windows or other unsupported module resources.
The core workflow consists of reading an unzipped Ignition project, duplicating its relevant components to a destination directory, and performing targeted modifications on bindings and scripts.
Before running the tool, you must configure the source and destination paths in config.py.
SOURCE_PROJECT_PATH: The path pointing to your source, unzipped Ignition project folder. To function correctly, this unzipped folder must contain scripts (ignition/script-python) and Perspective components (com.inductiveautomation.perspective/views).DESTINATION_PROJECT_PATH: The output directory where the modified project files will be saved. The application will create this folder if it doesn't exist.DATABASE_NAME: The name of the SQLite database file (e.g.,audit_mods.sqlite3) used to track all modifications.
When you run main.py, the tool begins by creating the destination directory. It selectively copies only the essential project structure from the source:
project.jsoncom.inductiveautomation.perspective/viewsignition/script-python
Once the files are staged in the destination folder, the application performs two primary passes:
- Perspective Views: Recursively parses
view.jsonfiles for Perspective views. It scans for script nodes, tag bindings, and query bindings, injecting modified structures where necessary. - Project Scripts: Scans all
.pyfiles within theignition/script-pythonlibrary. It searches for specific target functions (e.g.,system.tag.readBlocking,system.db.runNamedQuery) and modifies the code to wrap these calls with auditing logic.
For every injection or modification performed, the application logs a detailed record into the SQLite database specified in config.py.
The audit_mods table tracks:
- The specific
resource(script path or view path) that was modified. - The
bindingorfunctiontargeted. - The
linenumber orsizeof the modification. - The
mod_type(indicating what kind of injection occurred). - The
original_data(the exact script content or binding configuration before it was changed).
This database serves as an exhaustive audit trail, giving you full visibility into the modifications and allowing you to reference the original logic if needed.
-
Prepare Your Ignition Project:
- Export your project from the Ignition Gateway (
.zipformat). - Unzip the project archive into a folder on your local machine.
- Update: Make sure to add a session custom property
pageSelectedto your project to capture the page which the logging is pointed to.
- Export your project from the Ignition Gateway (
-
Configure the Tool:
- Open
config.py. - Set
SOURCE_PROJECT_PATHto the path of your unzipped project folder. - Set
DESTINATION_PROJECT_PATHto the desired output directory for the modified files. - Set
DATABASE_NAMEto your preferred SQLite file name.
- Open
-
Run the Modifier:
- Execute the main script using Python 3:
python main.py
- The script will output its progress to the console, detailing which views and scripts are being processed.
- Execute the main script using Python 3:
-
Review and Import:
- Open the generated SQLite database using any standard SQLite viewer to review the modifications.
- The modified components in your
DESTINATION_PROJECT_PATHcan now be zipped back into a.ziparchive (ensureproject.jsonis at the root of the zip) or dropped directly into your development Gateway'sdata/projects/directory.