Skip to content
This repository has been archived by the owner on Oct 7, 2019. It is now read-only.

Added method to check if firewall blocks .cs files #1261

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

CryptoJones
Copy link

@CryptoJones CryptoJones commented Nov 13, 2017

This is for issue: #1063

This adds a method to the CSharp plugin compiler to check if a client's proxy/firewall prevents downloading CSharp source files.

The changes compile and matches the formatting conventions and standards used.

Points to consider and limitations; The method needs to be invoked. I wasn't sure where to call it from, so I left it uncalled. This could be used extension wide to check all filetypes instead of just CSharp Files. If that is desired it will need to be moved outside the plugin compiler (I believe) and we will need to upload a file of each type somewhere and test each one inside the method.

// we can use any url below that contains a CSharp source file.
var request =
(HttpWebRequest)WebRequest.Create(
$"https://devdrop.blob.core.windows.net/downloads/FirewallTest.cs");
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't use a random plugin from a site that isn't controlled by us, there are plugins available on https://github.com/umods such as DevTest, though I don't see why this would help test this at all.

var statusCode = (int)response.StatusCode;
switch (statusCode)
{
case 401:
Copy link
Member

Choose a reason for hiding this comment

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

I don't see how checking for a valid response code would test if web requests are being blocked. If anything, you'd want no response or a response of 0.

Copy link
Author

Choose a reason for hiding this comment

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

I tested using squid & squidguard on my PFSense firewall. It gave 403 when denied, or 401 when set to required login/password for bypass. Other firewalls/content filters may display different behaviors.

@@ -494,5 +494,34 @@ private static string GetHash(string filePath, HashAlgorithm algorithm)
return BitConverter.ToString(hash).Replace("-", string.Empty).ToLower();
}
}

private static bool FirewallBlocking()
Copy link
Member

Choose a reason for hiding this comment

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

I don't think an entire method is needed, just check for a valid HTTP code in the existing downloading methods.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants