Skip to content

Commit b9c96b4

Browse files
committed
fixing the security scanning warnings
Signed-off-by: nikhil2611 <[email protected]>
1 parent 58ee0df commit b9c96b4

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

.github/workflows/lint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ name: lint
1010
- 17-stable
1111
- 16-stable
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
chefstyle:
1518
runs-on: ubuntu-latest

.github/workflows/sonarqube.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
- 'release/**'
1010
pull_request:
1111
types: [opened, synchronize, reopened]
12+
13+
permissions:
14+
contents: read
1215

1316
jobs:
1417
sonarqube:

lib/ohai/loader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def load_plugin_class(plugin_path)
100100
contents = ""
101101
begin
102102
logger.trace("Loading plugin at #{plugin_path}")
103-
contents << IO.read(plugin_path)
103+
contents << File.read(plugin_path)
104104
rescue IOError, Errno::ENOENT
105105
logger.warn("Unable to open or read plugin at #{plugin_path}")
106106
return nil

lib/ohai/mixin/ec2_metadata.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,11 @@ def fetch_dynamic_data
248248
private
249249

250250
def expand_path(file_name)
251-
path = file_name.gsub(/\=.*$/, "/")
251+
# Replace '=' only at the start of the string and avoid excessive backtracking
252+
path = file_name.sub(/^=+/, "/")
252253
# ignore "./" and "../"
253-
path.gsub(%r{/\.\.?(?:/|$)}, "/")
254-
.sub(%r{^\.\.?(?:/|$)}, "")
254+
path.gsub(%r{\/\.\.?(?:\/|$)}, "/")
255+
.sub(%r{^\.\.?(?:\/|$)}, "")
255256
.sub(/^$/, "/")
256257
end
257258

0 commit comments

Comments
 (0)