コンテンツ管理policyを設定する
コンテンツ管理 policy
コンテンツ管理およびシステム構成の説明については、Policy Managementを参照してください。
glasswall.content_management.policies.Policy クラスのサブクラスは、default および config キーワード引数を渡すことで、複雑さの異なるコンテンツ管理 policy を簡単に作成するために使用できます。
コンテンツ管理 policy の例を以下に示します。コンテンツ管理 policy が必要であっても、キーワード引数 content_management_policy で指定されていない場合は、デフォルトのコンテンツ管理 policy が使用されることに注意してください。
コンテンツ管理 policy は、Policy クラスのサブクラスを使用して指定できます。
Editor policy
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")
)
ファイルパスから 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=r"C:\gwpw\configs\config.xml"
)
以下に、policy の例と、Policy サブクラスを使用してそれらを作成する方法を示します。
Editor のデフォルトの 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 のカスタム 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>
content management policy 内の要素には属性を持たせることができます。属性は、キーの先頭に @ 文字を付けることで設定できます。
WordSearch policy
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>