Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Protect the service by not loading non-Managed assemblies #42

Merged
merged 5 commits into from
Apr 30, 2019
Merged
Changes from 4 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
15 changes: 13 additions & 2 deletions Services/DataX.Flow/Flow.ManagementService/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ private async Task<IEnumerable<Assembly>> GetDependencyAssembliesFromStorageAsyn

var dlls = blobStorage.GetCloudBlockBlobs(mefContainerName, mefBlobDirectory);

// Configure and create a logger instance
var logger = _loggerFactory.CreateLogger<Startup>();

foreach (var blob in dlls)
{
if (blob.Name.EndsWith(".dll"))
Expand All @@ -146,8 +149,16 @@ private async Task<IEnumerable<Assembly>> GetDependencyAssembliesFromStorageAsyn
{
await blob.DownloadToStreamAsync(strm);
byte[] asseblyBytes = strm.ToArray();
var assembly = Assembly.Load(asseblyBytes);
additionalAssemblies = additionalAssemblies.Append(assembly);
try
{
var assembly = Assembly.Load(asseblyBytes);
additionalAssemblies = additionalAssemblies.Append(assembly);
}
catch(BadImageFormatException be)
{
// do nothing and skip the assembly to load as it might be a native assembly
logger.LogError(be, "Unable to load Assembly: {0} from the StorageAccount", blob.Name);
}
}
}
}
Expand Down