forked from intel/cve-bin-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: perl language parser (intel#2614)
* fixes intel#1978
- Loading branch information
Showing
7 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ connman | |
conventionalcommits | ||
copyleft | ||
coreinfrastructure | ||
cpanfile | ||
cpio | ||
cpp | ||
CQA | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
"go", | ||
"swift", | ||
"php", | ||
"perl", | ||
] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (C) 2022 Intel Corporation | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from cve_bin_tool.parsers import Parser | ||
|
||
|
||
class PerlParser(Parser): | ||
def __init__(self, cve_db, logger): | ||
super().__init__(cve_db, logger) | ||
|
||
def run_checker(self, filename): | ||
self.filename = filename | ||
with open(self.filename) as fh: | ||
data = fh.readlines() | ||
# Split each line into tokens and find dependencies | ||
dependencies = [] | ||
for line in data: | ||
tokens = line.split() | ||
if len(tokens) >= 4 and tokens[0] == "requires" and tokens[2] == "=>": | ||
dependencies.append( | ||
( | ||
tokens[1].strip('"').split("::")[-1], | ||
tokens[3].strip("'").strip(";").strip('"'), | ||
) | ||
) | ||
elif len(tokens) >= 1 and tokens[0] == "requires": | ||
name = (tokens[1].strip('"').split("::")[-1],) | ||
self.logger.debug(f"Dependency with no version information: {name}") | ||
|
||
# Print the extracted dependencies | ||
for dependency in dependencies: | ||
vendor = self.find_vendor(dependency[0], dependency[1]) | ||
if vendor is not None: | ||
yield from vendor | ||
self.logger.debug(f"Done scanning file: {self.filename}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use strict; | ||
use warnings; | ||
|
||
requires "Carp" => "0"; | ||
requires "HTTP::Tiny" => "0.056"; | ||
requires "IO::Socket::SSL" => "1.42"; | ||
requires "JSON::MaybeXS" => "0"; | ||
requires "JSON::PP" => "0"; | ||
requires "Moo" => "0"; | ||
requires "Moo::Role" => "0"; | ||
requires "Net::SSLeay" => "1.49"; | ||
requires "Ref::Util" => "0"; | ||
requires "Safe::Isa" => "0"; | ||
requires "Type::Tiny" => "0"; | ||
requires "URI::Escape"; | ||
requires "perl" => "5.010"; | ||
requires "strict" => "0"; | ||
requires "warnings" => "0"; | ||
|
||
on 'test' => sub { | ||
requires "Test::Fatal" => "0"; | ||
requires "Test::More" => "0"; | ||
requires "Test::Needs" => "0.002005"; | ||
requires "base" => "0"; | ||
requires "blib" => "1.01"; | ||
requires "LWP::Protocol::https" => "0"; | ||
recommends "HTTP::Tiny::Mech" => "1.001002"; | ||
recommends "WWW::Mechanize::Cached" => "1.54"; | ||
}; | ||
|
||
on 'develop' => sub { | ||
requires "HTTP::Tiny::Mech" => "1.001002"; | ||
requires "LWP::Protocol::https" => "0"; | ||
requires "WWW::Mechanize::Cached" => "1.54"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters