8
n8n 中文网amn8n.com

使用Have I Been Pwned实时监控数据泄露

高级

这是一个Support, SecOps领域的自动化工作流,包含 24 个节点。主要使用 If, Set, Merge, SplitOut, HttpRequest 等节点。 使用Have I Been Pwned实时监控数据泄露

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "568298fde06d3db80a2eea77fe5bf45f0c7bb898dea20b769944e9ac7c6c5a80",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "eb8bbb43-d6ca-48f9-9522-12ac7100961d",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1360,
        380
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "77bf0c40-b045-40f9-9401-d1b206938180",
      "name": "转换为文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -360,
        -420
      ],
      "parameters": {
        "options": {},
        "operation": "toJson",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1.1
    },
    {
      "id": "c2e870c2-52e8-4808-9091-e3dcf286eaa5",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -660,
        20
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "data"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "2bcafdc1-94e0-4a3d-9ad5-a189973be980",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1500,
        -340
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a602fdf3-82d8-4bc1-806b-576b6fc904b7",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        -520
      ],
      "parameters": {
        "width": 760,
        "content": "### 当haveibeenpwned.com添加新数据泄露时接收警报"
      },
      "typeVersion": 1
    },
    {
      "id": "a53e7c76-0823-415f-91fd-920b354568d3",
      "name": "请求数据泄露",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1240,
        -340
      ],
      "parameters": {
        "url": "https://haveibeenpwned.com/api/v3/latestbreach",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "777c65aa-1bce-40eb-9de1-dd8fef4afd05",
      "name": "读取最后泄露",
      "type": "n8n-nodes-base.readWriteFile",
      "notes": "we alerted about.",
      "position": [
        -1020,
        -160
      ],
      "parameters": {
        "options": {},
        "fileSelector": "./cache.json"
      },
      "notesInFlow": true,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "d6638b7b-6209-497a-a176-91751a10bab1",
      "name": "从文件获取JSON",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -840,
        -80
      ],
      "parameters": {
        "options": {},
        "operation": "fromJson"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "42103453-54db-4d18-8d2b-9b56f5d3a3dd",
      "name": "检查内容",
      "type": "n8n-nodes-base.if",
      "position": [
        -480,
        20
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6bf6a0bd-e9b3-4fde-a9cc-08f4d0e94fd6",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.lastItem }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2dfa332e-9892-4385-a693-2ff2fc51f067",
      "name": "设置为无",
      "type": "n8n-nodes-base.set",
      "notes": "File was empty.",
      "position": [
        -300,
        80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "47736e3f-0961-4b73-b4d5-207792640e87",
              "name": "lastItem",
              "type": "string",
              "value": "none"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "6653599a-db6a-4a01-af5c-d79a2d58202f",
      "name": "如果 - 检查新泄露",
      "type": "n8n-nodes-base.if",
      "position": [
        -840,
        -340
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "badd0a56-081f-49e2-92f4-7711f1cd9289",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.lastItem }}",
              "rightValue": "={{ $json.Name }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "1f2cbeda-0c84-4b54-84ec-03a7b22f4471",
      "name": "设置泄露名称",
      "type": "n8n-nodes-base.set",
      "position": [
        -560,
        -420
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d0714936-9956-4af8-93f9-3c44ef7beb09",
              "name": "lastItem",
              "type": "string",
              "value": "={{ $json.Name }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "85314f2d-98d7-461a-a565-5202006ddd39",
      "name": "将泄露名称写入文件",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -180,
        -420
      ],
      "parameters": {
        "options": {},
        "fileName": "./cache.json",
        "operation": "write"
      },
      "typeVersion": 1
    },
    {
      "id": "e4cc122c-172f-4154-b534-c2c9268cf10d",
      "name": "新泄露",
      "type": "n8n-nodes-base.noOp",
      "notes": "Send alert",
      "position": [
        -560,
        -680
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "80b7507f-d5f2-4a3d-9090-784f80770478",
      "name": "旧泄露",
      "type": "n8n-nodes-base.noOp",
      "notes": "already alerted.",
      "position": [
        -560,
        -160
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "63f65fa4-fba1-4ab4-93ff-cd4df9068b19",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        -500
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 240,
        "content": "### 保存泄露名称"
      },
      "typeVersion": 1
    },
    {
      "id": "5a8dd017-e3e4-445e-be0f-24a8033d7dac",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 240,
        "content": "### 此泄露已被识别过"
      },
      "typeVersion": 1
    },
    {
      "id": "eb563c4a-54f5-4583-8fb1-e5ee5a14ca43",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        -760
      ],
      "parameters": {
        "color": 3,
        "width": 640,
        "height": 240,
        "content": "### 这是新泄露 - 发送警报"
      },
      "typeVersion": 1
    },
    {
      "id": "45b58d9b-7172-447d-91ab-e91e3516c8d9",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1220,
        300
      ],
      "parameters": {
        "color": 7,
        "width": 600,
        "height": 260,
        "content": "### 清理缓存"
      },
      "typeVersion": 1
    },
    {
      "id": "bb2401d2-716c-47eb-9797-5b69583058ee",
      "name": "设置空JSON",
      "type": "n8n-nodes-base.set",
      "position": [
        -1180,
        380
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "69f35659-fd32-4fa7-969e-6cf266519f5b",
              "name": "data",
              "type": "string",
              "value": "{}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c3abbf86-50f2-4772-bc7c-9a57ac39d4a3",
      "name": "写入cache.json",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -840,
        380
      ],
      "parameters": {
        "options": {},
        "fileName": "./cache.json",
        "operation": "write"
      },
      "typeVersion": 1
    },
    {
      "id": "69f03dd6-11f0-41e6-8871-9b17c44ef2fe",
      "name": "将JSON转换为文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -1000,
        380
      ],
      "parameters": {
        "options": {},
        "operation": "toJson"
      },
      "typeVersion": 1.1
    },
    {
      "id": "2cf6adf9-59e4-4450-b7f8-96907155da84",
      "name": "添加关于上次警报泄露的信息",
      "type": "n8n-nodes-base.merge",
      "position": [
        -1020,
        -340
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3
    },
    {
      "id": "80e38061-140a-4c78-b49c-dcf796da1427",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1480,
        -100
      ],
      "parameters": {
        "color": 6,
        "width": 380,
        "height": 240,
        "content": "## 支持我的工作!❤️"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Split Out": {
      "main": [
        [
          {
            "node": "Check for content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set to none": {
      "main": [
        [
          {
            "node": "Add information about the last breach we alerted",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Set empty json": {
      "main": [
        [
          {
            "node": "Convert json to file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Write breach name to file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set breach name": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read last breach": {
      "main": [
        [
          {
            "node": "Get JSON from file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request breaches": {
      "main": [
        [
          {
            "node": "Read last breach",
            "type": "main",
            "index": 0
          },
          {
            "node": "Add information about the last breach we alerted",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Request breaches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for content": {
      "main": [
        [
          {
            "node": "Add information about the last breach we alerted",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Set to none",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get JSON from file": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If - check for new": {
      "main": [
        [
          {
            "node": "Set breach name",
            "type": "main",
            "index": 0
          },
          {
            "node": "New breach",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Old breach",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert json to file": {
      "main": [
        [
          {
            "node": "Write cache.json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write breach name to file": {
      "main": [
        []
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Set empty json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add information about the last breach we alerted": {
      "main": [
        [
          {
            "node": "If - check for new",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 客户支持, 安全运维

需要付费吗?

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

工作流信息
难度等级
高级
节点数量24
分类2
节点类型12
难度说明

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

作者
Audun

Audun

@xqus

Transforming complexity into simplicity.

外部链接
在 n8n.io 查看

分享此工作流