6.3. 使用 YAML 文件进行 redaction
当您将 YAML 文件用于 redaction 时,两个文件控制 redaction 操作:
-
file-redaction.yaml
-
file-content-redaction.yaml
您可以根据您要进行发布的内容,使用一个或多个文件。当 Python SoS 进程运行时,它会在归档文件中捕获之前对指定的内容进行重新处理。
如果您运行 Red Hat Enterprise Linux 6.10、7.9、8.3 及更新的版本,请使用这个 redaction 方法。
YAML 文件的工作方式
/etc/insights-client/file-redaction.yaml
列出您要重新处理的命令和文件。当进程运行时,它会清除列出的命令和文件的输出。
/etc/insights-client/file-content-redaction.yaml
定义模式 redaction 和 keyword 替换。对于模式 redaction,进程红色模式或正则表达式,与 YAML 文件中指定的匹配。对于关键字替换,进程会将指定的关键字替换为通用标识符。
6.3.1. 为文件 redaction 配置 YAML 命令
/etc/insights-client/file-redaction.yaml
文件列出了您要重新处理的命令和系统文件。当 Python SoS 进程运行时,它不会在上传的存档文件中包含列出的命令或文件的输出。
先决条件
- 您必须熟悉 YAML 语法的基础知识。解释 YAML 超出了此流程范围。
- 您必须具有系统的根级别访问权限。
流程
使用编辑器创建
/etc/insights-client/file-redaction.yaml
文件。示例
# file-redaction.yaml --- # Exclude the entire output of commands # Specify the full command path or the symbolic name in .cache.json commands: - /bin/rpm -qa - /bin/ls - ethtool_i # Exclude the entire output of files # Specify the full filename path or the symbolic name in .cache.json files: - /etc/audit/auditd.conf - cluster_conf
验证是否只为
root
所有者设置了file-redaction.yaml
文件权限。[root@insights]# ll file-redaction.yaml -rw-------. 1 root root 145 Sep 25 17:39 file-redaction.yaml
6.3.2. 配置 YAML 模式和关键字 redaction
/etc/insights-client/file-content-redaction.yaml
文件使用两种方法: pattern redaction 和 keyword 替换。pattern redaction 使用模式匹配或正则表达式匹配。在关键字替换中,Python SoS 进程使用通用标识符替换关键字。
先决条件
- 您必须熟悉 YAML 语法的基础知识。解释 YAML 超出了此流程范围。
- 您必须具有系统的根级别访问权限。
流程
使用编辑器创建
/etc/insights-client/file-content-redaction.yaml
文件。示例
# file-content-redaction.yaml --- # Pattern redaction per matching line # Lines that match a pattern are excluded from files and command output. # Patterns are processed in the order that they are listed. # Example patterns: - "a_string_1" - "a_string_2" # Regular expression pattern redaction per line # Use "regex:" to wrap patterns with regular expressions" # Example patterns: regex: - "abc.*def" - "localhost[[:digit:]]" # Keyword replacement redaction # Replace keywords in files and command output with generic identifiers # Keyword does not support regex # Example keywords: - "1.1.1.1" - "My Name" - "a_name"
确保只为
root
所有者设置file-content-redaction.yaml
文件权限。[root@insights]# ll file-content-redaction.yaml -rw-------. 1 root root 145 Sep 25 17:39 file-content-redaction.yaml