Content Management Policies
See Policy Management for content management and system configuration descriptions.
Subclasses of the glasswall.content_management.policies.Policy
class can be used to easily create content management policies of varying complexity by passing the default
and config
keyword arguments.
Some examples of content management policies are below. Note that if a content management policy is required but has not been specified with the keyword argument content_management_policy
then the default content management policy will be used.
Content management policies can be specified using subclasses of the Policy
class:
Editor Policies
Setting an Editor policy
import glasswall
# Load the Glasswall Editor library
editor = glasswall.Editor(r"C:\gwpw\libraries\10.0")
editor.protect_directory(
input_directory=r"C:\gwpw\input",
output_directory=r"C:\input_sanitised",
content_management_policy=glasswall.content_management.policies.Editor(default="sanitise")
)
Setting an Editor policy from file path
import glasswall
# Load the Glasswall Editor library
editor = glasswall.Editor(r"C:\gwpw\libraries\10.0")
editor.protect_directory(
input_directory=r"C:\gwpw\input",
output_directory=r"C:\input_sanitised",
content_management_policy=r"C:\gwpw\configs\config.xml"
)
Some examples of policies and how to create them using the Policy subclasses are shown below.
Editor default sanitise all policy
import glasswall
# Print the default Editor content management policy
print(glasswall.content_management.policies.Editor(default="sanitise"))
<?xml version="1.0" encoding="utf-8"?>
<config>
<pdfConfig>
<acroform>sanitise</acroform>
<actions_all>sanitise</actions_all>
<digital_signatures>sanitise</digital_signatures>
<embedded_files>sanitise</embedded_files>
<embedded_images>sanitise</embedded_images>
<external_hyperlinks>sanitise</external_hyperlinks>
<internal_hyperlinks>sanitise</internal_hyperlinks>
<javascript>sanitise</javascript>
<metadata>sanitise</metadata>
</pdfConfig>
<pptConfig>
<embedded_files>sanitise</embedded_files>
<embedded_images>sanitise</embedded_images>
<external_hyperlinks>sanitise</external_hyperlinks>
<internal_hyperlinks>sanitise</internal_hyperlinks>
<javascript>sanitise</javascript>
<macros>sanitise</macros>
<metadata>sanitise</metadata>
<review_comments>sanitise</review_comments>
</pptConfig>
<sysConfig>
<interchange_pretty>false</interchange_pretty>
<interchange_type>sisl</interchange_type>
</sysConfig>
<tiffConfig>
<geotiff>sanitise</geotiff>
</tiffConfig>
<wordConfig>
<dynamic_data_exchange>sanitise</dynamic_data_exchange>
<embedded_files>sanitise</embedded_files>
<embedded_images>sanitise</embedded_images>
<external_hyperlinks>sanitise</external_hyperlinks>
<internal_hyperlinks>sanitise</internal_hyperlinks>
<macros>sanitise</macros>
<metadata>sanitise</metadata>
<review_comments>sanitise</review_comments>
</wordConfig>
<xlsConfig>
<dynamic_data_exchange>sanitise</dynamic_data_exchange>
<embedded_files>sanitise</embedded_files>
<embedded_images>sanitise</embedded_images>
<external_hyperlinks>sanitise</external_hyperlinks>
<internal_hyperlinks>sanitise</internal_hyperlinks>
<macros>sanitise</macros>
<metadata>sanitise</metadata>
<review_comments>sanitise</review_comments>
</xlsConfig>
</config>
Editor custom allow all policy
import glasswall
# Print a custom Editor content management policy with a default of allow
# that only sanitises macros in wordConfig, and embedded images and files in
# xlsConfig
print(glasswall.content_management.policies.Editor(
default="allow",
config={
"wordConfig": {
"macros": "sanitise",
},
"xlsConfig": {
"embedded_files": "sanitise",
"embedded_images": "sanitise",
},
}
))
<?xml version="1.0" encoding="utf-8"?>
<config>
<pdfConfig>
<acroform>allow</acroform>
<actions_all>allow</actions_all>
<digital_signatures>allow</digital_signatures>
<embedded_files>allow</embedded_files>
<embedded_images>allow</embedded_images>
<external_hyperlinks>allow</external_hyperlinks>
<internal_hyperlinks>allow</internal_hyperlinks>
<javascript>allow</javascript>
<metadata>allow</metadata>
</pdfConfig>
<pptConfig>
<embedded_files>allow</embedded_files>
<embedded_images>allow</embedded_images>
<external_hyperlinks>allow</external_hyperlinks>
<internal_hyperlinks>allow</internal_hyperlinks>
<javascript>allow</javascript>
<macros>allow</macros>
<metadata>allow</metadata>
<review_comments>allow</review_comments>
</pptConfig>
<sysConfig>
<default>allow</default>
<interchange_pretty>false</interchange_pretty>
<interchange_type>sisl</interchange_type>
</sysConfig>
<tiffConfig>
<geotiff>allow</geotiff>
</tiffConfig>
<wordConfig>
<dynamic_data_exchange>allow</dynamic_data_exchange>
<embedded_files>allow</embedded_files>
<embedded_images>allow</embedded_images>
<external_hyperlinks>allow</external_hyperlinks>
<internal_hyperlinks>allow</internal_hyperlinks>
<macros>sanitise</macros>
<metadata>allow</metadata>
<review_comments>allow</review_comments>
</wordConfig>
<xlsConfig>
<dynamic_data_exchange>allow</dynamic_data_exchange>
<embedded_files>sanitise</embedded_files>
<embedded_images>sanitise</embedded_images>
<external_hyperlinks>allow</external_hyperlinks>
<internal_hyperlinks>allow</internal_hyperlinks>
<macros>allow</macros>
<metadata>allow</metadata>
<review_comments>allow</review_comments>
</xlsConfig>
</config>
Elements within a content management policy may have attributes. Attributes can be set by prefixing a key with the @
character.
WordSearch Policies
Setting a WordSearch policy
import glasswall
# Print a custom Word Search content management policy with a default of
# allow. Redact instances of the string "lorem" by replacing each character
# with an asterisk, and redact instances of the string "ipsum" by replacing
# each character with the letter "X".
print(glasswall.content_management.policies.WordSearch(
default="allow",
config={
"textSearchConfig": {
"textList": [
{"name": "textItem", "switches": [
{"name": "text", "value": "lorem"},
{"name": "textSetting", "@replacementChar": "*", "value": "redact"},
]},
{"name": "textItem", "switches": [
{"name": "text", "value": "ipsum"},
{"name": "textSetting", "@replacementChar": "X", "value": "redact"},
]},
]
}
}
))
<?xml version="1.0" encoding="utf-8"?>
<config>
<pdfConfig>
<acroform>allow</acroform>
<actions_all>allow</actions_all>
<digital_signatures>allow</digital_signatures>
<embedded_files>allow</embedded_files>
<embedded_images>allow</embedded_images>
<external_hyperlinks>allow</external_hyperlinks>
<internal_hyperlinks>allow</internal_hyperlinks>
<javascript>allow</javascript>
<metadata>allow</metadata>
</pdfConfig>
<pptConfig>
<embedded_files>allow</embedded_files>
<embedded_images>allow</embedded_images>
<external_hyperlinks>allow</external_hyperlinks>
<internal_hyperlinks>allow</internal_hyperlinks>
<javascript>allow</javascript>
<macros>allow</macros>
<metadata>allow</metadata>
<review_comments>allow</review_comments>
</pptConfig>
<sysConfig>
<export_embedded_images>true</export_embedded_images>
<interchange_best_compression>false</interchange_best_compression>
<interchange_pretty>false</interchange_pretty>
<interchange_type>xml</interchange_type>
</sysConfig>
<textSearchConfig libVersion="core2">
<textList>
<textItem>
<text>lorem</text>
<textSetting replacementChar="*">redact</textSetting>
</textItem>
<textItem>
<text>ipsum</text>
<textSetting replacementChar="X">redact</textSetting>
</textItem>
</textList>
</textSearchConfig>
<tiffConfig>
<geotiff>allow</geotiff>
</tiffConfig>
<wordConfig>
<dynamic_data_exchange>allow</dynamic_data_exchange>
<embedded_files>allow</embedded_files>
<embedded_images>allow</embedded_images>
<external_hyperlinks>allow</external_hyperlinks>
<internal_hyperlinks>allow</internal_hyperlinks>
<macros>allow</macros>
<metadata>allow</metadata>
<review_comments>allow</review_comments>
</wordConfig>
<xlsConfig>
<dynamic_data_exchange>allow</dynamic_data_exchange>
<embedded_files>allow</embedded_files>
<embedded_images>allow</embedded_images>
<external_hyperlinks>allow</external_hyperlinks>
<internal_hyperlinks>allow</internal_hyperlinks>
<macros>allow</macros>
<metadata>allow</metadata>
<review_comments>allow</review_comments>
</xlsConfig>
</config>
API Documentation
https://glasswall-python-wrapper-documentation.glasswall.com/