SpamHaus/cfn-templates/SpamHausDropIPFiltering.yaml [132:187]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                  console.log("Fetched " + listOfIps.length + " IP addresses...");
                  resolve();
                });
                res.on('error', (err) => {
                  reject(err);
                });
              });
              post_req.end();
            });
          }

          let updateRules = async function (ruleGroup) {
            let params = ruleGroup;
            delete params.Capacity;
            params.RuleGroupName = params.RuleGroupResponse.RuleGroupName;
            params.Type = params.RuleGroupResponse.Type;
            delete params.RuleGroupResponse;

            console.log("Updating rules...");
            let res = await networkfirewall.updateRuleGroup(params).promise();
            if (res) {
              console.log("Updated '" + params.RuleGroupName + "'.");
            } else {
              console.log("Error updating the rules for '" + params.RuleGroupName + "'...");
            }
            return;
          };

          let createRules = async function (ruleGroup, type) {
            if (listOfIps.length == 0) {
              await fetchIPs();
            } else {
              console.log("Using recently fetched list of " + listOfIps.length + " IP addresses...");
            }

            let rulesString = "# Last updated: " + new Date().toUTCString() + "\n";
            rulesString += "# Using a list of " + listOfIps.length + " IP addresses\n";
            
            listOfIps.forEach((ip, index) => {
              rulesString += type + ' ip ' + ip + ' any -> any any (msg:"' + type + ' emerging threats traffic from ' + ip + '"; rev:1; sid:55' + index + ';)\n';
              rulesString += type + ' ip any any -> ' + ip + ' any (msg:"' + type + '  emerging threats traffic to ' + ip + '"; rev:1; sid:66' + index + ';)\n';
            });

            ruleGroup.RuleGroup.RulesSource.RulesString = rulesString;
            await updateRules(ruleGroup);

            return;
          };

          exports.handler = async (event, context) => {
              if (event.RequestType == "Delete") {
                await response.send(event, context, "SUCCESS");
                return;
            }

            var params = {Type: "STATEFUL", RuleGroupArn: '${StatefulRulegroup.RuleGroupArn}'};
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



TorProject/cfn-templates/TorProjectIPFiltering.yaml [134:189]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                  console.log("Fetched " + listOfIps.length + " IP addresses...");
                  resolve();
                });
                res.on('error', (err) => {
                  reject(err);
                });
              });
              post_req.end();
            });
          }

          let updateRules = async function (ruleGroup) {
            let params = ruleGroup;
            delete params.Capacity;
            params.RuleGroupName = params.RuleGroupResponse.RuleGroupName;
            params.Type = params.RuleGroupResponse.Type;
            delete params.RuleGroupResponse;

            console.log("Updating rules...");
            let res = await networkfirewall.updateRuleGroup(params).promise();
            if (res) {
              console.log("Updated '" + params.RuleGroupName + "'.");
            } else {
              console.log("Error updating the rules for '" + params.RuleGroupName + "'...");
            }
            return;
          };

          let createRules = async function (ruleGroup, type) {
            if (listOfIps.length == 0) {
              await fetchIPs();
            } else {
              console.log("Using recently fetched list of " + listOfIps.length + " IP addresses...");
            }

            let rulesString = "# Last updated: " + new Date().toUTCString() + "\n";
            rulesString += "# Using a list of " + listOfIps.length + " IP addresses\n";
            
            listOfIps.forEach((ip, index) => {
              rulesString += type + ' ip ' + ip + ' any -> any any (msg:"' + type + ' emerging threats traffic from ' + ip + '"; rev:1; sid:55' + index + ';)\n';
              rulesString += type + ' ip any any -> ' + ip + ' any (msg:"' + type + ' emerging threats traffic to ' + ip + '"; rev:1; sid:66' + index + ';)\n';
            });

            ruleGroup.RuleGroup.RulesSource.RulesString = rulesString;
            await updateRules(ruleGroup);

            return;
          };

          exports.handler = async (event, context) => {
            if (event.RequestType == "Delete") {
                await response.send(event, context, "SUCCESS");
                return;
            }

            var params = {Type: "STATEFUL", RuleGroupArn: '${StatefulRulegroup.RuleGroupArn}'};
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



