8
n8n 中文网amn8n.com

将Jamf策略导出为CSV到Slack进行即时审计

高级

这是一个SecOps领域的自动化工作流,包含 19 个节点。主要使用 Set, Xml, Slack, Webhook, SplitOut 等节点。 将Jamf策略导出为CSV到Slack进行即时审计

前置要求
  • Slack Bot Token 或 Webhook URL
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "894b3446666dc2807d20dfad165e2f6f3696905c2f8c352081f4fd666cdd7b1c",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "5ca81fc1-614a-4631-8c7c-e5245be5cf17",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        -112
      ],
      "parameters": {
        "width": 260,
        "height": 320,
        "content": "## 设置"
      },
      "typeVersion": 1
    },
    {
      "id": "ba77dd94-871d-42ff-821d-197568974504",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -112
      ],
      "parameters": {
        "color": 3,
        "width": 188,
        "height": 320,
        "content": "## 获取"
      },
      "typeVersion": 1
    },
    {
      "id": "7d304368-ae37-4508-b76d-d9f5dca6e353",
      "name": "点击",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -640,
        80
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "359efbe9-baef-4136-85e2-ace0e53d0f21",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        528,
        32
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "361358cd-6e1a-4453-8d2b-5c1aa1f23476",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -112
      ],
      "parameters": {
        "color": 6,
        "width": 170,
        "height": 320,
        "content": "## 拆分"
      },
      "typeVersion": 1
    },
    {
      "id": "d8ba1ba1-d77d-4062-801a-83a594b266a1",
      "name": "Jamf 服务器",
      "type": "n8n-nodes-base.set",
      "position": [
        -368,
        48
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d5945b47-962f-4cea-8bb8-a8f61ee468ec",
              "name": "server",
              "type": "string",
              "value": "youserver"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0f55f295-4b0c-49d4-8d99-2658d17742a2",
      "name": "XML",
      "type": "n8n-nodes-base.xml",
      "onError": "continueRegularOutput",
      "position": [
        752,
        -96
      ],
      "parameters": {
        "options": {},
        "dataPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "b72b34e8-2c7c-4b19-81bf-a4bbfa730dd0",
      "name": "Webhook-policies",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -640,
        -112
      ],
      "webhookId": "",
      "parameters": {
        "path": "",
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "ef2147db-2fc3-4906-ac31-864666bd755e",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        -112
      ],
      "parameters": {
        "color": 2,
        "width": 188,
        "height": 320,
        "content": "## 转换"
      },
      "typeVersion": 1
    },
    {
      "id": "f3e2dd39-75d2-4021-80a2-ba252066474e",
      "name": "XML-JSON",
      "type": "n8n-nodes-base.xml",
      "position": [
        96,
        48
      ],
      "parameters": {
        "options": {},
        "dataPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "bebaba2f-376e-4b3e-96af-7c9424f26108",
      "name": "拆分策略 ID",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        320,
        48
      ],
      "parameters": {
        "include": "selectedOtherFields",
        "options": {},
        "fieldToSplitOut": "policies.policy",
        "fieldsToInclude": "server"
      },
      "typeVersion": 1
    },
    {
      "id": "0ffca65c-85dc-47e6-96a1-a2ccfa79056e",
      "name": "获取策略 ID",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -128,
        48
      ],
      "parameters": {
        "url": "=https://{{ $json.server }}.jamfcloud.com/JSSResource/policies",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/xml"
            }
          ]
        }
      },
      "credentials": {
        "oAuth2Api": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9ce5001c-3bb2-4afb-9e99-a6995e7a59ad",
      "name": "获取策略:id",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        752,
        80
      ],
      "parameters": {
        "url": "=https://{{ $('Jamf Server').item.json.server }}.jamfcloud.com/JSSResource/policies/id/{{ $json['policies.policy'].id }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/xml"
            }
          ]
        }
      },
      "credentials": {
        "oAuth2Api": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d73f87b7-a4c2-4ac2-9986-fe4ba78e45b3",
      "name": "发布到 Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        1456,
        -96
      ],
      "webhookId": "4ae7b233-a125-4249-b76c-226b26340331",
      "parameters": {
        "options": {
          "fileName": "Policies.csv",
          "channelId": ""
        },
        "resource": "file"
      },
      "credentials": {
        "slackApi": {
          "id": "8kwaKSXWJHzDApmZ",
          "name": "Slack"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "6e5d07d9-6ef0-4a0b-b800-bcd6c1b4dc0c",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        -240
      ],
      "parameters": {
        "color": 4,
        "width": 470,
        "height": 520,
        "content": "## 循环"
      },
      "typeVersion": 1
    },
    {
      "id": "a9352d9b-b4d4-4a42-b1f7-9a311312485b",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        976,
        -240
      ],
      "parameters": {
        "height": 360,
        "content": "## 设置"
      },
      "typeVersion": 1
    },
    {
      "id": "46f2f4ce-a981-465c-a5af-4d4316164385",
      "name": "Set-fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1040,
        -96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "bfeee80d-4878-4e0b-b4b1-84c648f901ff",
              "name": "ID",
              "type": "number",
              "value": "={{ $json.policy.general.id }}"
            },
            {
              "id": "be741659-a897-4190-837c-1e91958cd26f",
              "name": "Policy Name",
              "type": "string",
              "value": "={{ $json.policy.general.name }}"
            },
            {
              "id": "b69579f9-200b-4960-b985-62ccddf1251d",
              "name": "Category",
              "type": "string",
              "value": "={{ $json.policy.general.category.name }}"
            },
            {
              "id": "10420196-7d61-463b-ab21-b74929e1d0cb",
              "name": "Trigger",
              "type": "string",
              "value": "={{ $json.policy.general.trigger }}"
            },
            {
              "id": "fcfa2c98-d7b7-46cd-91a7-09f10c743ea6",
              "name": "Frequency",
              "type": "string",
              "value": "={{ $json.policy.general.frequency }}"
            },
            {
              "id": "744213ce-da86-4b07-9707-63c28dcbd5f0",
              "name": "Scope - Computers",
              "type": "string",
              "value": "={{ \n  $json.policy.scope.all_computers === \"true\"\n    ? \"All\"\n    : Array.isArray($json.policy.scope.computers?.computer)\n      ? $json.policy.scope.computers.computer.length\n      : $json.policy.scope.computers?.computer\n        ? \"1\"\n        : \"None\"\n}}\n"
            },
            {
              "id": "dc229e19-652a-4c92-9b76-e4f4eae15c13",
              "name": "Self Service",
              "type": "string",
              "value": "={{ $json.policy.self_service.use_for_self_service }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fd80fda5-d6c8-4b26-b45c-7d60571064b2",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 340,
        "height": 360,
        "content": "## 转换和发送"
      },
      "typeVersion": 1
    },
    {
      "id": "59596d74-768a-4e0f-9074-80580d1b5bf6",
      "name": "转换",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1280,
        -96
      ],
      "parameters": {
        "options": {},
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1.1
    }
  ],
  "pinData": {},
  "connections": {
    "XML": {
      "main": [
        [
          {
            "node": "Set-fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Click": {
      "main": [
        [
          {
            "node": "Jamf Server",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert": {
      "main": [
        [
          {
            "node": "Post to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "XML-JSON": {
      "main": [
        [
          {
            "node": "Split Policies ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set-fields": {
      "main": [
        [
          {
            "node": "Convert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Jamf Server": {
      "main": [
        [
          {
            "node": "Get Policies ids",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Policy:id": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "XML",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Policy:id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Policies ids": {
      "main": [
        [
          {
            "node": "XML-JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook-policies": {
      "main": [
        [
          {
            "node": "Jamf Server",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Policies ID": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 安全运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量19
分类1
节点类型10
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
外部链接
在 n8n.io 查看

分享此工作流