Skip to content
This repository was archived by the owner on Jun 2, 2022. It is now read-only.

Commit 7063e2e

Browse files
check if can read the file (permission)
1 parent 804acd9 commit 7063e2e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/nflabs/Grok/Grok.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ public int addPatternFromFile( String file) throws Throwable{
118118
File f = new File(file);
119119
if(!f.exists())
120120
return GrokError.GROK_ERROR_FILE_NOT_ACCESSIBLE;
121+
if( !f.canRead() )
122+
return GrokError.GROK_ERROR_FILE_NOT_ACCESSIBLE;
121123

122124
BufferedReader br = new BufferedReader(new FileReader(file));
123125
String line;
@@ -191,10 +193,11 @@ public int compile( String pattern ){
191193
}
192194
_captured_map.put( "name"+index, (group.get("subname") != null ? group.get("subname"):group.get("name")));
193195
_expanded_pattern = StringUtils.replace(_expanded_pattern, "%{"+group.get("name")+"}", "(?<name"+index+">" + this.patterns.get(group.get("pattern"))+")");
194-
//System.out.println(expanded_pattern);
196+
//System.out.println(_expanded_pattern);
195197
index++;
196198
}
197199
}
200+
//System.out.println(_captured_map);
198201
//Compile the regex
199202
if(!_expanded_pattern.isEmpty()){
200203
_regexp = Pattern.compile(_expanded_pattern);

0 commit comments

Comments
 (0)