Skip to content

Commit e3b6b4c

Browse files
author
Felipe Zimmerle
committed
Fix resource load on ip match from file
1 parent 6f718f9 commit e3b6b4c

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
v3.0.x - YYYY-MMM-DD (To be released)
22
-------------------------------------
33

4+
- Fixed resource load on ip match from file
5+
[#1674 - @zimmerle, @StefaanSeys]
46
- Fixed examples compilation while using disable-shared
57
[#1670 - @zimmerle, @ivanbaldo]
68
- Fixed compilation issue while xml is disabled

src/operators/ip_match_from_file.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
#include "src/operators/ip_match_from_file.h"
17+
#include "src/utils/system.h"
1718

1819
#include <string.h>
1920

@@ -33,7 +34,11 @@ bool IpMatchFromFile::init(const std::string &file,
3334
if (m_param.compare(0, 8, "https://") == 0) {
3435
res = m_tree.addFromUrl(m_param, &e);
3536
} else {
36-
res = m_tree.addFromFile(m_param, &e);
37+
std::string resf = utils::find_resource(m_param, file, error);\
38+
if (resf == "") {
39+
return false;
40+
}
41+
res = m_tree.addFromFile(resf, &e);
3742
}
3843

3944
if (res == false) {

test/test-cases/regression/operator-ipMatchFromFile.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
]
8181
},
8282
"expected":{
83-
"parser_error":"File: operator-ipMatchFromFile.json. Line: 2. Column: 19. Failed to open file: file-not-found.txt"
83+
"parser_error":"Rules error. File: operator-ipMatchFromFile.json. Line: 2. Column: 19. Looking at: 'file-not-found.txt', 'file-not-found.txt', 'operator-ipMatchFromFile.json/file-not-found.txt', 'operator-ipMatchFromFile.json/file-not-found.txt'."
8484
},
8585
"rules":[
8686
"SecRuleEngine On",

0 commit comments

Comments
 (0)