Skip to content

Commit

Permalink
Tweaked logic of DebianLookup and UbuntuLookup.
Browse files Browse the repository at this point in the history
  • Loading branch information
RoliSoft committed Jun 28, 2016
1 parent 79759ac commit 9cc4b6a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions DebianLookup.cpp
Expand Up @@ -46,7 +46,7 @@ unordered_map<string, string> DebianLookup::FindVulnerability(const string& cve,
// pkg -> name of the package
// dist -> distribution (stable, unstable, etc)
// ver -> version which fixes the vulnerability
static regex tblrgx("href=\"\\/tracker\\/source-package\\/[^\"]+\">(?<pkg>[^<]+)<\\/a><\\/td><td>[^<]*<\\/td><td>\\(?(?<dist>[^<\\)]+)\\)?<\\/td><td>(?<ver>[^<]+)<\\/td>", regex::icase);
static regex tblrgx("href=\"\\/tracker\\/source-package\\/[^\"]+\">(?<pkg>[^<]+)<\\/a><\\/td><td>[^<]*<\\/td><td>\\(?(?<dist>[^<\\)]+)\\)?<\\/td><td>(?:\\d:)?(?<ver>[^<]+)<\\/td>", regex::icase);

sregex_iterator srit(html.begin(), html.end(), tblrgx);
sregex_iterator end;
Expand Down Expand Up @@ -105,7 +105,14 @@ vector<pair<string, long>> DebianLookup::GetChangelog(const string& pkg, OpSys d
}
}

auto resp = getURL("https://packages.debian.org/" + dver + "/" + pkg);
auto dpkg = pkg;

if (dpkg == "openssh")
{
dpkg = "openssh-server";
}

auto resp = getURL("https://packages.debian.org/" + dver + "/" + dpkg);

if (get<2>(resp) != 200)
{
Expand All @@ -128,7 +135,7 @@ vector<pair<string, long>> DebianLookup::GetChangelog(const string& pkg, OpSys d

if (!regex_search(get<0>(resp), chlurl, chlrgx))
{
log(ERR, "Failed get changelog location for the package " + pkg + ".");
log(ERR, "Failed get changelog location for the package " + dpkg + ".");
return updates;
}

Expand Down
13 changes: 10 additions & 3 deletions UbuntuLookup.cpp
Expand Up @@ -47,7 +47,7 @@ unordered_map<string, string> UbuntuLookup::FindVulnerability(const string& cve,
// dist -> distribution (xenial, trusty, etc)
// status -> vulnerability status (safe, vuln)
// ver -> if fixed, version which fixes the vulnerability
static regex tblrgx("href=\"[^l]+launchpad\\.net\\/ubuntu\\/(?<dist>[^\\/]+)\\/[^\\/]+\\/(?<pkg>[^\"]+)\">[^<]+<\\/a>[^<]*<\\/td><td><span class=\"(?<status>[^\"]+)\">[^<]+<\\/span>(?:\\s*\\((?<ver>[^\\)]+))?", regex::icase);
static regex tblrgx("href=\"[^l]+launchpad\\.net\\/ubuntu\\/(?<dist>[^\\/]+)\\/[^\\/]+\\/(?<pkg>[^\"]+)\">[^<]+<\\/a>[^<]*<\\/td><td><span class=\"(?<status>[^\"]+)\">[^<]+<\\/span>(?:\\s*\\((?:\\d:)?(?<ver>[^\\)]+))?", regex::icase);

sregex_iterator srit(html.begin(), html.end(), tblrgx);
sregex_iterator end;
Expand Down Expand Up @@ -96,7 +96,14 @@ vector<pair<string, long>> UbuntuLookup::GetChangelog(const string& pkg, OpSys d
}
}

auto resp = getURL("http://packages.ubuntu.com/" + dver + "/" + pkg);
auto dpkg = pkg;

if (dpkg == "openssh")
{
dpkg = "openssh-server";
}

auto resp = getURL("http://packages.ubuntu.com/" + dver + "/" + dpkg);

if (get<2>(resp) != 200)
{
Expand All @@ -119,7 +126,7 @@ vector<pair<string, long>> UbuntuLookup::GetChangelog(const string& pkg, OpSys d

if (!regex_search(get<0>(resp), chlurl, chlrgx))
{
log(ERR, "Failed get changelog location for the package " + pkg + ".");
log(ERR, "Failed get changelog location for the package " + dpkg + ".");
return updates;
}

Expand Down

0 comments on commit 9cc4b6a

Please sign in to comment.