[3/4] ids-functions.pl: Add function to get the info url for a given rule id

Message ID 20260209142322.2481-3-stefan.schantl@ipfire.org
State New
Headers
Series [1/4] ruleset-sources: Add details about rule sid and info URL |

Commit Message

Stefan Schantl 9 Feb 2026, 2:23 p.m. UTC
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 config/cfgroot/ids-functions.pl | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
  

Patch

diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl
index 0271ef4fc..93d1acdee 100644
--- a/config/cfgroot/ids-functions.pl
+++ b/config/cfgroot/ids-functions.pl
@@ -1909,4 +1909,29 @@  sub is_sid_in_range($\@) {
 	return undef;
 }
 
+#
+## Function to get the sid info url in case it is defined
+#
+sub get_sid_info_url($) {
+	my ($sid) = @_;
+
+	# Call function to get the provider for this rule id.
+	my $provider = &get_provider_by_sid($sid);
+
+	# Exit if no provder could be determined.
+	return unless($provider);
+
+	# Exit if no info URL is known for the provider.
+	return unless($IDS::Ruleset::Providers{$provider}{"sid_info_url"});
+
+	# Grab the URL for the given provider.
+	my $info_url = $IDS::Ruleset::Providers{$provider}{"sid_info_url"};
+
+	# Replace the <sid> placeholder with the given sid.
+	$info_url =~ s/\<sid\>/$sid/g;
+
+	# Return the URL.
+	return $info_url;
+}
+
 1;