Skip to content

Commit 101344b

Browse files
committed
Refactored previous changes.
1 parent 579df3d commit 101344b

File tree

6 files changed

+24
-41
lines changed

6 files changed

+24
-41
lines changed

BannerProcessor.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
using namespace std;
44

5+
void BannerProcessor::Scan(Service* service)
6+
{
7+
if (service->banner == nullptr)
8+
{
9+
return;
10+
}
11+
12+
auto matches = Scan(string(service->banner, service->banlen));
13+
14+
service->cpe.insert(service->cpe.end(), matches.begin(), matches.end());
15+
}
16+
517
BannerProcessor::~BannerProcessor()
618
{
719
}

BannerProcessor.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ class BannerProcessor
1414
*
1515
* \param service Scanned service.
1616
*/
17-
virtual void Scan(Service* service) = 0;
17+
void Scan(Service* service);
18+
19+
/*!
20+
* Processes the specified service banner.
21+
*
22+
* \param banner Service banner.
23+
*
24+
* \return Matching CPE entries.
25+
*/
26+
virtual std::vector<std::string> Scan(const std::string& banner) = 0;
1827

1928
/*!
2029
* Frees up the resources allocated during the lifetime of this instance.

CpeDictionaryMatcher.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@ using namespace boost;
88
vector<struct CpeEntry*> CpeDictionaryMatcher::entries = vector<struct CpeEntry*>();
99
unordered_map<string, vector<string>*> CpeDictionaryMatcher::aliases = unordered_map<string, vector<string>*>();
1010

11-
void CpeDictionaryMatcher::Scan(Service* service)
12-
{
13-
if (service->banner == nullptr)
14-
{
15-
return;
16-
}
17-
18-
auto matches = Scan(string(service->banner, service->banlen));
19-
20-
service->cpe.insert(service->cpe.end(), matches.begin(), matches.end());
21-
}
22-
2311
vector<string> CpeDictionaryMatcher::Scan(const string& banner)
2412
{
2513
if (entries.size() == 0)

CpeDictionaryMatcher.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,14 @@ class CpeDictionaryMatcher : public BannerProcessor
5858
{
5959
public:
6060

61-
/*!
62-
* Processes the banner of a service.
63-
*
64-
* \param service Scanned service.
65-
*/
66-
void Scan(Service* service) override;
67-
6861
/*!
6962
* Processes the specified service banner.
7063
*
7164
* \param banner Service banner.
7265
*
7366
* \return Matching CPE entries.
7467
*/
75-
std::vector<std::string> Scan(const std::string& banner);
68+
std::vector<std::string> Scan(const std::string& banner) override;
7669

7770
/*!
7871
* Gets the CPE entries.

ServiceRegexMatcher.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ using namespace boost;
77

88
vector<struct ServiceRegex*> ServiceRegexMatcher::regexes = vector<struct ServiceRegex*>();
99

10-
void ServiceRegexMatcher::Scan(Service* service)
11-
{
12-
if (service->banner == nullptr)
13-
{
14-
return;
15-
}
16-
17-
auto matches = Scan(string(service->banner, service->banlen));
18-
19-
service->cpe.insert(service->cpe.end(), matches.begin(), matches.end());
20-
}
21-
2210
vector<string> ServiceRegexMatcher::Scan(const string& banner)
2311
{
2412
if (regexes.size() == 0)

ServiceRegexMatcher.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,14 @@ class ServiceRegexMatcher : public BannerProcessor
3939
{
4040
public:
4141

42-
/*!
43-
* Processes the banner of a service.
44-
*
45-
* \param service Scanned service.
46-
*/
47-
void Scan(Service* service) override;
48-
4942
/*!
5043
* Processes the specified service banner.
5144
*
5245
* \param banner Service banner.
5346
*
5447
* \return Matching CPE entries.
5548
*/
56-
std::vector<std::string> Scan(const std::string& banner);
49+
std::vector<std::string> Scan(const std::string& banner) override;
5750

5851
/*!
5952
* Gets the regular expressions.

0 commit comments

Comments
 (0)