#TRUSTED 2f47e5193142d78a3ddf3b251b9c554a849d7b773224c3b4108e989a12e297659444616c748c3daeac054334620a393f767b76c2b19065f114c85dcb7fa368f26b12ee8cd2d8aab5f6fea549fd82c7a7ab79906c1c697a0134bf04d9aca7c86e70fd16d6a9359f47567fd6613431cd57c8cd6e96d4161a45dd957f3b96ed22a332d061bc51e067b69d6ddd0fba8f598de69c0840c2e40b6151f2f6027e181835ce7adc1b0be281c1db5809aafa127b4c974ca96f035c1aa4127a73477886f6a85d73b94f88fab4321a5ab154f8f8f32a4f5129e51a92332a7d7b964da203bb10eb3d11f4abca9b05d8df47f7701373c804201ff44d6ac58c3b053bcfe69f53d09b1c379776d85e4ede187296f32a2738927b4f5e52c703ad3092df5912b6034d4bfb47da64356b0d1bac18a1404a8c6127410f397418cbf990740adc1a7330bbe6b7c55277d4a19d421ccdf9ec5c343491054cb633b087d53f9f4bbe51ddec7319276f67a202a274027640bc26b26c59437b523daa31178bfb1ef6557c0734775732fc321043f0c2c3f95ffe4589ae3f98d9c7da06c660fbd016e52f782839aa50c18d8622b14459d7042551c8350c7c2bb524f371badca3e28e0c67adb5eb2047b7a030cf055a0c013376b77dcb1a4945a7db31ac3d76eb29c33b8e815ba7a54c419f3c628541ffd8de30c3d47789b0b822d813caf20eb68deb3b41a59687be
#TRUST-RSA-SHA256 7a5780bcdb21ebb82b4df67a0caadf3f7feef10623d31ae36ea5829110207bc05b26d813affaebfa6a6e5388cf9603d367a949acb97bf0271b05fef8cc6fb8c364639a6d58564e0aef5eeb6fdc4981bd914ef302383efd561367c296106b386393bfc219b542bc4586ef8f9ace56e92f2e2482ec21e0288c771b9cdb93f3480f6abe8982effc5abe31b3ecf8971cf720da0f9d3f368261a73ab034376c7c6916d477417fb1e0977e8b9ead3dafe6100456c997c270c95e9c52b327a1cfbef0a30d7941c11f569da57db910f23fd7af71dee646c8ca2d164fca8ba7fb5b0f168089b7d0de356a41d35fb05211ebadeb2f9dd3a28e6629ce22b449f701543438267224dbb8d12ca4bde8362ee0b27283a312f0b4a5168e5a753d4c04679399df7b7de9de692c16e2500d9adc0235a008df9186bc7a119e91cf0938d9b6a78fe4fa69895f8d9e0169e0c3f96e03a97120974b174e49a1c168175bed49602ebadab103b463e120149fbc41661877ed1df8ba322b05aa2232c33d884fe7a44cd51ac51333b2454c74a476c85917d2dfcdd8f96aff85f64c5721359b6301421d8ff8e95eb66a7955506ce719052523e17545c40b65e6e1a89b68fa2aacd84869a0d3e058e855b2eb5b615212aeb01990ada4c618f52bfa95ef426a55cf256e8348c08f2a06913927c38bee4bfd9f9fa857789281730eed9b1e97ec45207ddfcff35a82
#%NASL_MIN_LEVEL 80900
##
# (C) Tenable, Inc.
##
include('compat.inc');
if (description)
{
script_id(234444);
script_version("1.2");
script_set_attribute(attribute:"plugin_modification_date", value:"2026/04/29");
script_name(english:"Gather Source Package Manager Packages (nix)");
script_set_attribute(attribute:"synopsis", value:"Gather the source package data to be used by future plugins.");
script_set_attribute(attribute:"description", value:
"Gather and store the source package data for rpm and dpkg package managers
for future use during the scan.");
script_set_attribute(attribute:"solution", value:"n/a");
script_set_attribute(attribute:"risk_factor", value:"None");
script_set_attribute(attribute:"plugin_publication_date", value:"2025/05/07");
script_set_attribute(attribute:"agent", value:"unix");
script_set_attribute(attribute:"plugin_type", value:"local");
script_end_attributes();
script_category(ACT_GATHER_INFO);
script_family(english:"General");
script_copyright(english:"This script is Copyright (C) 2025-2026 and is owned by Tenable, Inc. or an Affiliate thereof.");
script_dependencies("unix_enum_sw.nasl");
script_require_ports("Host/uname");
exit(0);
}
include("debug.inc");
include("ssh_func.inc");
namespace set_source_packages
{
##
# Setup the connections and requirements for this plugin to run
#
# @return [array], contains ssh_sock if not localhost
#
# @remark this function exits if requirements are not met
##
function init()
{
var return_settings = {};
get_kb_item_or_exit('Host/local_checks_enabled');
var uname_kb = get_kb_item_or_exit("Host/uname");
if ("Linux" >!< uname_kb)
{
audit(AUDIT_OS_NOT, "Linux");
}
enable_ssh_wrappers();
if (islocalhost())
{
if (!defined_func("pread")) audit(AUDIT_FN_UNDEF,"pread");
info_t = INFO_LOCAL;
}
else
{
sock_g = ssh_open_connection();
if (!sock_g) audit(AUDIT_FN_FAIL, 'ssh_open_connection');
info_t = INFO_SSH;
return_settings["ssh_sock"] = sock_g;
}
return return_settings;
}
##
# Get source RPM packages and associated child packages from the target.
#
# @return [array] Array of package names and their associated source package.
##
function set_rpm_source_packages() {
var package_source_mapping = {};
var rpm_buf = info_send_cmd(cmd:"/bin/rpm -qa --qf '%{NAME},%{SOURCERPM}\n'");
dbg::detailed_log(lvl:4, msg:rpm_buf);
var lines = split(rpm_buf, keep:FALSE);
foreach var line ( lines )
{
# Validate line matches expected package to source rpm mapping format.
if(line =~ '^.+?,.+?\\-.+?\\-.+?\\.src\\.rpm$')
{
var entry = split(line, sep:',', keep:FALSE);
var pkg_name = entry[0];
var src_rpm = entry[1];
src_rpm = src_rpm - ".src.rpm";
# RPM src packages have the format NAME-VERSION-RELEASE.src.rpm
# The NAME can also contain '-' characters.
# The follow code strips off the -VERSION-RELEASE.src.rpm portion of the source rpm.
var src_pkg_parts = split(src_rpm, sep:'-', keep:FALSE);
var src_pkg = src_pkg_parts[0];
# Build the NAME up leaving off -VERSION-RELEASE.src.rpm
for(var i = 1; i < max_index(src_pkg_parts)-2; i++)
{
src_pkg += '-' + src_pkg_parts[i];
}
set_kb_item(name:"srcpackage/rpm/Package/"+pkg_name, value:src_pkg);
set_kb_item(name:"srcpackage/rpm/source/"+src_rpm, value:pkg_name);
package_source_mapping[pkg_name] = src_pkg; # used for easy access to the entire mapping later
}
}
if (!isnull(get_one_kb_item("srcpackage/rpm/Package/*")))
{
set_kb_item(name:"srcpackage/set/rpm", value:true);
set_kb_item(name:"srcpackage/rpm/package_source_mapping", value:serialize(package_source_mapping));
return true;
}
return false;
}
##
# Get source DPKG packages and associated child packages from the target.
#
# @return [array] Array of package names and their associated source package.
##
function set_dpkg_source_packages() {
var package_source_mapping = {};
var dpkg_buf = info_send_cmd(cmd:"dpkg-query -W -f '${Package},${source:Package}\n'");
dbg::detailed_log(lvl:4, msg:dpkg_buf);
var lines = split(dpkg_buf, keep:FALSE);
foreach var line ( lines )
{
# Format PACKAGE_NAME,SOURCE_PACKAGE_NAME
# Names are valid Linux file names and cannot contain '/'
var match = pregmatch(pattern:'^([^/]+),([^/]+)$', string:line);
if(!isnull(match))
{
set_kb_item(name:"srcpackage/dpkg/Package/"+match[1], value:match[2]);
set_kb_item(name:"srcpackage/dpkg/source/"+match[2], value:match[1]);
package_source_mapping[match[1]] = match[2]; # used for easy access to the entire mapping later
}
}
if (!isnull(get_one_kb_item("srcpackage/dpkg/Package/*")))
{
set_kb_item(name:"srcpackage/set/dpkg", value:true);
set_kb_item(name:"srcpackage/dpkg/package_source_mapping", value:serialize(package_source_mapping));
return true;
}
return false;
}
function close()
{
if (info_t == INFO_SSH) ssh_close_connection();
}
}
set_source_packages::init();
set_source_packages::set_dpkg_source_packages();
set_source_packages::set_rpm_source_packages();
set_source_packages::close();
Data
Build on a solid foundation with Vulners data
We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data
Api
Power your application with Vulners API
The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access
App
Assess and manage vulnerabilities with Vulners tools
Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation