Thiết lập các policy quản lý nội dung
Các policy quản lý nội dung
Xem Policy Management để biết mô tả về quản lý nội dung và cấu hình hệ thống.
Các lớp con của lớp glasswall.content_management.policies.Policy có thể được օգտագործ để dễ dàng tạo các policy quản lý nội dung với mức độ phức tạp khác nhau bằng cách truyền các đối số từ khóa default và config.
Dưới đây là một số ví dụ về policy quản lý nội dung. Lưu ý rằng nếu cần một policy quản lý nội dung nhưng chưa được chỉ định bằng đối số từ khóa content_management_policy thì policy quản lý nội dung mặc định sẽ được sử dụng.
Các policy quản lý nội dung có thể được chỉ định bằng các lớp con của lớp Policy:
Policy Editor
Thiết lập một policy 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")
)
Thiết lập một policy Editor từ đường dẫn tệp
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"
)
Dưới đây là một số ví dụ về policy và cách tạo chúng bằng các lớp con của Policy.
Policy Editor mặc định sanitise tất cả
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>
Policy tùy chỉnh cho Editor cho phép tất cả
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>
Các phần tử trong một policy quản lý nội dung có thể có thuộc tính. Có thể đặt thuộc tính bằng cách thêm tiền tố @ vào trước một khóa.
Các policy WordSearch
Thiết lập một policy 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>