Skip to content

Commit

Permalink
Fix CodeQL static analysis compliance warnings (#7144)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamYoblick authored Aug 30, 2022
1 parent e5d5550 commit 421d001
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Python/Product/Cookiecutter/Model/FeedTemplateSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private async Task BuildCacheAsync() {
_cache = new List<Template>();

try {
ServicePointManager.CheckCertificateRevocationList = true;
var client = new WebClient();
var feed = await client.DownloadStringTaskAsync(_feedLocation);
var feedUrls = feed.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
Expand Down
1 change: 1 addition & 0 deletions Python/Product/Cookiecutter/Model/GitHubClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public async Task<bool> FileExistsAsync(GitHubRepoSearchItem repo, string filePa
}

private static WebClient CreateClient() {
ServicePointManager.CheckCertificateRevocationList = true;
var wc = new WebClient();
wc.Encoding = Encoding.UTF8;
wc.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public virtual Stream Connect(Uri uri, bool requireAuthentication) {
// of inactivity, making it impossible to attach. So before trying to connect to the debugger, "ping" the website
// via HTTP to ensure that we have something to connect to.
try {
ServicePointManager.CheckCertificateRevocationList = true;
var httpRequest = WebRequest.Create(new UriBuilder(uri) { Scheme = "http", Port = -1, Path = "/" }.Uri);
httpRequest.Method = WebRequestMethods.Http.Head;
httpRequest.Timeout = 5000;
Expand Down
3 changes: 3 additions & 0 deletions Python/Product/DebuggerHelper/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,9 @@ static void TraceLine(void* frame) {

void* f_code = ReadField<void*>(frame, fieldOffsets.PyFrameObject.f_code);
void* co_filename = ReadField<void*>(f_code, fieldOffsets.PyCodeObject.co_filename);
if (co_filename == nullptr) {
return;
}

auto fileNamesOffsets = reinterpret_cast<const int32_t*>(bpData.fileNamesOffsets);
auto strings = reinterpret_cast<const char*>(bpData.strings);
Expand Down
1 change: 1 addition & 0 deletions Python/Product/ProjectWizards/CookiecutterWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ private static Uri Resolve(Uri uri) {
return uri;
}

ServicePointManager.CheckCertificateRevocationList = true;
var req = WebRequest.CreateHttp(uri);
req.Method = "HEAD";
req.AllowAutoRedirect = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private static void CopyOneFile(Uri destination, IPublishFile item) {
EnsureDirectoryExists(rootPath, destinationDir);

// upload the file
ServicePointManager.CheckCertificateRevocationList = true;
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri(newLoc));
request.Method = WebRequestMethods.Ftp.UploadFile;
byte[] buffer = new byte[1024];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ private void HandleDisplayXaml() {

_eval.InvokeAsync(() => {
try {
// This can potentially instantiate any random subclass of FrameworkElement,
// but that's OK and expected.
var fe = XamlReader.Load(new MemoryStream(buffer)) as FrameworkElement;
if (fe != null) {
_eval.WriteFrameworkElement(fe, fe.DesiredSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public async Task<PackageSpec> GetPackageInfoAsync(PackageSpec entry, Cancellati
}

try {
ServicePointManager.CheckCertificateRevocationList = true;
using (var client = new WebClient()) {
Stream data;
client.Headers[HttpRequestHeader.UserAgent] = UserAgent;
Expand Down

0 comments on commit 421d001

Please sign in to comment.