Itakda ang mga policy sa pamamahala ng nilalaman
Mga policy sa content management
Tingnan ang Policy Management para sa mga paglalarawan ng pamamahala ng content at configuration ng system.
Maaaring gamitin ang mga subclass ng class na glasswall.content_management.policies.Policy upang madaling makagawa ng mga content management policy na may iba’t ibang antas ng pagiging kumplikado sa pamamagitan ng pagpasa ng mga keyword argument na default at config.
Nasa ibaba ang ilang halimbawa ng mga content management policy. Tandaan na kung kailangan ang isang content management policy ngunit hindi ito naitakda gamit ang keyword argument na content_management_policy, gagamitin ang default na content management policy.
Maaaring tukuyin ang mga content management policy gamit ang mga subclass ng class na Policy:
Mga policy ng Editor
Pagtatakda ng policy ng Editor
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")
)
Pagtatakda ng policy ng Editor mula sa 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"
)
Nasa ibaba ang ilang halimbawa ng mga policy at kung paano gawin ang mga ito gamit ang mga subclass ng Policy.
Default na sanitise all policy ng Editor
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>
Custom na allow all policy ng Editor
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>
Ang mga element sa loob ng isang content management policy ay maaaring may mga attribute. Maaaring itakda ang mga attribute sa pamamagitan ng paglalagay ng prefix na @ sa isang key.
Mga policy ng WordSearch
Pagtatakda ng policy ng WordSearch
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>