From patchwork Wed Jan 22 13:40:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 2715 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 482mkk1p3kz3xYC for ; Wed, 22 Jan 2020 13:40:46 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 482mkh5DB6z2t2; Wed, 22 Jan 2020 13:40:44 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909ed25519; t=1579700445; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WjYfan1UsGEsIQmATSkBaUUkgGyrCSV5Rd7AVDh7c70=; b=8U2TCbI5rTScD7yv037N5mx9S34DnA6K5wqXBoKfSYF+ThSKaHqzGbjM6aTrncM7mS/LHX IoQWVzHmdAXeEUAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909rsa; t=1579700445; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WjYfan1UsGEsIQmATSkBaUUkgGyrCSV5Rd7AVDh7c70=; b=PBToUdVS32aN7261CH/Os2mtZpN4a7EGuOF8XdT314LWZ/9bhezj93N/JC8Dg5pk6ti9AH VID7pETNsEefHZLQ4mKI5wxhABJUG1a8SRHBbQQ5mDTbf/JZzDJcU4KJ5DR6hcx7tSne4G 6C2CB52wE7ObZan16LZbz9ljyF7oc3pr06ooprR66VuDUYwEd5YR/iiSqa+PmYuImXvW4p zRSnHBe9GjR0NcpiftfMhenzib53z4TD2sbCNUUuRXPEYPCOVqywpIdrnhoGOaG2z0gd/a Sd87Pq/eKTEuUw0BHN9Ia+88yzdq3G+TuZ4HKeLny0LxQAOEBQ97Q+4Hb/JkLQ== Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 482mkh3f43z2yCC; Wed, 22 Jan 2020 13:40:44 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 482mkf696Tz2xfm for ; Wed, 22 Jan 2020 13:40:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 482mkf1dqBz2jX; Wed, 22 Jan 2020 13:40:42 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909ed25519; t=1579700442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WjYfan1UsGEsIQmATSkBaUUkgGyrCSV5Rd7AVDh7c70=; b=uO6hy96b3/DXcwNQrCBBx4gLTB70dg1/x5+xNBWqGDH8IpbJrC1IUy0dXyt1NL5SnnYkTw TnWcM1mML12AKwBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909rsa; t=1579700442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WjYfan1UsGEsIQmATSkBaUUkgGyrCSV5Rd7AVDh7c70=; b=B+TQgpDrAXA569jyHdW9izVI93vCU+237LXcofGX9DYlUI8eCsrknJyAOOY8crFEfPivji Bccaan/jxlCKoVfrgK9+Dx9hRc2nohVZKRxmJN3UzOEWuMC2TWY7Ndx9nLP2aWyhFn3lTW 5isUxnSyMrDLcBh1WyM/giLN07RE2b50OzW69t3KB/w21fFqqxvi2FTfvZsd6mx0M1Q3D/ go9Scihe6fcYIMWqJFbbQ+lrr0ozLpEcj645HujugQymlZ4t1L34d08Cl+wbVSDreH7VOc JbKzCMl0OnhoOEC0MmOydLxkIGGNMiv5WECviDOI3Du4mumSLxTx9FFbPasb1g== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH] ids-functions.pl: Introduce file for local rules. Date: Wed, 22 Jan 2020 14:40:34 +0100 Message-Id: <20200122134034.2729-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.auth=stevee smtp.mailfrom=stefan.schantl@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" This file is to be used, to store customized IDS rules. Signed-off-by: Stefan Schantl Reviewed-by: Michael Tremer --- config/cfgroot/ids-functions.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl index 3fa19fab7..3cfe837db 100644 --- a/config/cfgroot/ids-functions.pl +++ b/config/cfgroot/ids-functions.pl @@ -67,6 +67,9 @@ our $ids_page_lock_file = "/tmp/ids_page_locked"; # Location where the rulefiles are stored. our $rulespath = "/var/lib/suricata"; +# Location to store local rules. This file will not be touched. +our $local_rules_file = "$rulespath/local.rules"; + # File which contains the rules to whitelist addresses on suricata. our $whitelist_file = "$rulespath/whitelist.rules"; @@ -581,6 +584,9 @@ sub _cleanup_rulesdir() { # Skip rules file for whitelisted hosts. next if ("$rulespath/$file" eq $whitelist_file); + # Skip rules file with local rules. + next if ("$rulespath/$file" eq $local_rules_file); + # Delete the current processed file, if not, exit this function # and return an error message. unlink("$rulespath/$file") or return "Could not delete $rulespath/$file. $!\n";