Skip to content

Commit e0b6aaa

Browse files
committed
semgrep updates
1 parent ed01d09 commit e0b6aaa

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

.semgrepignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Ignore test and example files containing dummy credentials
2+
23
**/test/**/*.json
34
**/tests/**/*.json
45
**/SampleRequests/**/*.json
@@ -7,6 +8,12 @@
78
**/*.min.js
89
**/env.configs.yml
910

11+
# ignore template files
12+
Blueprints/BlueprintDefinitions/vs2017/*/template/**
13+
Blueprints/BlueprintDefinitions/vs2019/*/template/**
14+
Blueprints/BlueprintDefinitions/vs2022/*/template/**
15+
Libraries/test/*/**
16+
1017
# Ignore third-party libraries
1118
**/node_modules/**
1219
**/vendor/**

Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/SampleRequests/SampleRequestManager.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public string GetRequest(string name)
9696
{
9797
name = name.Substring(name.IndexOf("@") + 1);
9898
var savedRequestDirectory = GetSavedRequestDirectory();
99-
var path = Path.Combine(savedRequestDirectory, name);
99+
var sanitizedName = Path.GetFileName(name);
100+
var path = Path.Combine(savedRequestDirectory, sanitizedName);
100101
return File.ReadAllText(path);
101102
}
102103
return GetEmbeddedResource(name);
@@ -110,7 +111,8 @@ public string SaveRequest(string name, string content)
110111
if (!Directory.Exists(savedRequestDirectory))
111112
Directory.CreateDirectory(savedRequestDirectory);
112113

113-
File.WriteAllText(Path.Combine(savedRequestDirectory, filename), content);
114+
var sanitizedFilename = Path.GetFileName(filename);
115+
File.WriteAllText(Path.Combine(savedRequestDirectory, sanitizedFilename), content);
114116
return $"{SavedRequestDirectory}@{filename}";
115117
}
116118

Tools/LambdaTestTool/src/Amazon.Lambda.TestTool.BlazorTester/Startup.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,15 @@ public void ConfigureServices(IServiceCollection services)
109109
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
110110
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
111111
{
112-
app.UseDeveloperExceptionPage();
112+
if (env.IsDevelopment())
113+
{
114+
app.UseDeveloperExceptionPage();
115+
}
116+
else
117+
{
118+
app.UseExceptionHandler("/Error");
119+
app.UseHsts();
120+
}
113121

114122
app.UseStaticFiles();
115123

Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/SampleRequests/SampleRequestManager.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ public string GetRequest(string name)
102102
if(name.StartsWith(SAVED_REQUEST_DIRECTORY + "@"))
103103
{
104104
name = name.Substring(name.IndexOf("@") + 1);
105-
var path = Path.Combine(this.GetSavedRequestDirectory(), name);
105+
var sanitizedName = Path.GetFileName(name); // Sanitize the filename to prevent path traversal
106+
var path = Path.Combine(this.GetSavedRequestDirectory(), sanitizedName);
106107
return File.ReadAllText(path);
107108
}
108109
return GetEmbeddedResource(name);
@@ -146,4 +147,4 @@ public string GetSavedRequestDirectory()
146147
return path;
147148
}
148149
}
149-
}
150+
}

0 commit comments

Comments
 (0)