yookd / pulledpork

Automatically exported from code.google.com/p/pulledpork
GNU General Public License v2.0
0 stars 0 forks source link

Error 500 when fetching rules / using http_proxy #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the product are you using? On what operating system?
pulledpork-0.5.0 on CentOS 5.5

Please provide any additional information below.
Follow up on issue #36...

Tested the new pp with proxy and it wasn't working. Requests were not being 
sent through proxy and received the following output...

MY HTTPS PROXY = http://user:pass@webproxy.company.com:9090
Checking latest MD5 for snortrules-snapshot-2861.tar.gz....
    Fetching md5sum for: snortrules-snapshot-2861.tar.gz.md5
    Error 500 when fetching https://www.snort.org/reg-rules/snortrules-snapshot-2861.tar.gz.md5 at /export/scripts/pulledpork.pl line 390
    main::md5file('oinkcode', 'snortrules-snapshot-2861.tar.gz', '/tmp/', 'https://www.snort.org/reg-rules/') called at /export/scripts/pulledpork.pl line 1386

Please see below for code that is working for me. 

# set some UserAgent and other connection configs
$ua->agent("$VERSION");
# Note, this doesn't work on CentOS 5.5 (outdated LWP::UserAgent)
#$ua->show_progress(1) if $Verbose; 

# New Settings to allow proxy connections to use proper SSL formating - Thx 
pkthound!
$ua->timeout(15);
$ua->cookie_jar( {} );
$ua->protocols_allowed( [ 'http', 'https' ] );
my $proxy = $ENV{http_proxy};

if ($proxy) {
    $ua->proxy( ['http'], $proxy );

    # Check if credentials are in proxy url
    if ( $proxy =~ /^http:\/\/(.+):(.+)@(.+)$/i ) {
        my $user = $1;
        my $pass = $2;
        my $proxy = $3;

        $ENV{HTTPS_PROXY} = "http://" . $proxy;
        $ENV{HTTPS_PROXY_USERNAME} = $user;
        $ENV{HTTPS_PROXY_PASSWORD} = $pass;

        #print "Proxy: $proxy\n";
        #print "User: $user\n";
        #print "Pass: $pass\n";

   }
   else {
      $ENV{HTTPS_PROXY} = $proxy;
   }
}

Thanks

James

Original issue reported on code.google.com by jdaf...@gmail.com on 25 Oct 2010 at 6:53

GoogleCodeExporter commented 9 years ago
Forgot the end quote on this line:
$ENV{HTTPS_PROXY} = "http://" . $proxy;

I should also mention that the above fix does not require both http_proxy and 
https_proxy to be set. It derives the value of https_proxy from http_proxy 
(which is the way I think it should be unless you are using 2 different proxy 
servers???).

James

Original comment by jdaf...@gmail.com on 25 Oct 2010 at 7:41

GoogleCodeExporter commented 9 years ago
James,

We will have a look into this for verification etc...

JJC

Original comment by Cummin...@gmail.com on 26 Oct 2010 at 5:42

GoogleCodeExporter commented 9 years ago
this is only caused when a username/pass is required for the proxy, will fix in 
0.5.1 to be forthcoming!

Original comment by Cummin...@gmail.com on 27 Oct 2010 at 8:09

GoogleCodeExporter commented 9 years ago
Great! Thanks!

Original comment by jdaf...@gmail.com on 28 Oct 2010 at 10:47

GoogleCodeExporter commented 9 years ago

Original comment by Cummin...@gmail.com on 29 Oct 2010 at 11:48

GoogleCodeExporter commented 9 years ago
So I'm gonna do a few things here, 

1: changing your regex just a bit
2: testing for unique variables (http and https) and if on is not set, use that 
value to set the other (though I agree with you)
3: that's it.. look for a code commit soon to svn and another comment to this 
bug

Original comment by Cummin...@gmail.com on 5 Nov 2010 at 1:14

GoogleCodeExporter commented 9 years ago
Committed if yo want to test 'er out

Original comment by Cummin...@gmail.com on 5 Nov 2010 at 1:46

GoogleCodeExporter commented 9 years ago
Setting to fixed unless I hear otherwise

Original comment by Cummin...@gmail.com on 8 Nov 2010 at 5:47

GoogleCodeExporter commented 9 years ago
Finally got a chance to test it out today and it works as expected. Thanks!

Original comment by jdaf...@gmail.com on 8 Nov 2010 at 7:58

GoogleCodeExporter commented 9 years ago
Issue 57 has been merged into this issue.

Original comment by Cummin...@gmail.com on 11 Jan 2011 at 7:16