Skip to content

semgrep updates #2067

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .semgrepignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Ignore test and example files containing dummy credentials

**/test/**/*.json
**/tests/**/*.json
**/SampleRequests/**/*.json
Expand All @@ -7,6 +8,12 @@
**/*.min.js
**/env.configs.yml

# ignore template files
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these template files had warnings for some of the controllers not having authorization but i figure for templates it doesnt matter. same thing with some of the ones in test

Blueprints/BlueprintDefinitions/vs2017/*/template/**
Blueprints/BlueprintDefinitions/vs2019/*/template/**
Blueprints/BlueprintDefinitions/vs2022/*/template/**
Libraries/test/*/**

# Ignore third-party libraries
**/node_modules/**
**/vendor/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public string GetRequest(string name)
{
name = name.Substring(name.IndexOf("@") + 1);
var savedRequestDirectory = GetSavedRequestDirectory();
var path = Path.Combine(savedRequestDirectory, name);
var sanitizedName = Path.GetFileName(name);
var path = Path.Combine(savedRequestDirectory, sanitizedName);
return File.ReadAllText(path);
}
return GetEmbeddedResource(name);
Expand All @@ -110,7 +111,8 @@ public string SaveRequest(string name, string content)
if (!Directory.Exists(savedRequestDirectory))
Directory.CreateDirectory(savedRequestDirectory);

File.WriteAllText(Path.Combine(savedRequestDirectory, filename), content);
var sanitizedFilename = Path.GetFileName(filename);
File.WriteAllText(Path.Combine(savedRequestDirectory, sanitizedFilename), content);
return $"{SavedRequestDirectory}@{filename}";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ public void ConfigureServices(IServiceCollection services)
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseDeveloperExceptionPage();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}

app.UseStaticFiles();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public string GetRequest(string name)
if(name.StartsWith(SAVED_REQUEST_DIRECTORY + "@"))
{
name = name.Substring(name.IndexOf("@") + 1);
var path = Path.Combine(this.GetSavedRequestDirectory(), name);
var sanitizedName = Path.GetFileName(name); // Sanitize the filename to prevent path traversal
var path = Path.Combine(this.GetSavedRequestDirectory(), sanitizedName);
return File.ReadAllText(path);
}
return GetEmbeddedResource(name);
Expand Down Expand Up @@ -146,4 +147,4 @@ public string GetSavedRequestDirectory()
return path;
}
}
}
}
Loading