PhantomJS failing on remote ajax field check - ajax

I developed a script to complete & submit a remote form via PhantomJS (version 2.1). For testing I built a local approximation of the remote form which included an ajax field check upon input (so, you enter an email address in the email field, and after a second it checks to see if it's a valid input). My phantom script fills out the fields, waits a few seconds for an error to be thrown, and then carries on to submit the form if everything looks okay. This all worked just fine with everything running on localhost.
However, as soon as I switch to making the call to the remote webpage (which is a third-party site; I have no access to make changes to it), it fails when the remote page performs the ajax check on fields. I have the following onResourceError function:
page.onResourceError = function(resourceError) {
system.stderr.writeLine('= onResourceError()');
system.stderr.writeLine(' - unable to load url: "' + resourceError.url + '"');
system.stderr.writeLine(' - error code: ' + resourceError.errorCode + ', description: ' + resourceError.errorString );
};
...and if I run the following line (in a Windows command prompt):
phantomjs.exe form-process.js "https://contact.site.com/auth/form?params=that&are=always&the=same" "clarence#email.com"
I get the following error:
https://contact.site.com/ajax/email-check?email=clarence#email.com"
- error code: 302,
- description: Error downloading "https://contact.site.com/ajax/email-check?email=clarence#email.com"
- server replied: Bad request
I am running this from a local environment but with no SSL certificate installed, so I assumed (based on the description of the 302 error code: the requested operation is invalid for this protocol) that it was a cross-protocol issue. But running the phantomJS line with any combination of --ssl-protocol=any, --ignore-ssl-errors=yes or --web-security=false yields the same results.
I may be misunderstanding these modes for phantomJS, but I assumed that --ssl-protocol=any would dismiss this issue, but would I still need to have a local SSL cert to get this to work? Or is there another issue here?

Related

why is the ansible sros_command module responding with an error from a role, but works independently

I am attempting to send a command to an SROS device using an ansible role. The task itself is:
- name: invoke the sros cli
sros_command:
commands: ["{{item.input}}"]
register: sros_command_result
This command is being run inside a loop of several commands. I know that the module will allow you to send multiple commands at once, but I need to do additional processing on each command so its simpler to handle them individually. I've verified that item.input is correct, and the notation is sending the command as a list which is what the module wants for input.
In the case I am testing the command itself is show chassis.
I have verified that I am connected to the device, and an independent debug run of the module only generates the correct response from the device.
When I run this via my role though, it response with: "Unable to decode JSON from response to exec_command('{\"command\": \"show chassis\", \"prompt\": null, \"answer\": null}'). Received 'None'."
Im very lost. I do not know why this error is appearing (other than the device not sending a response), nor can I figure out any way to debug this.

TeamCity: Customize build failed error message (include it in email)

We are using TeamCity to process hundreds of builds. We added a custom command line script which prints an error to console, and if the enviroment variable TEAMCITY_VERSION is set, then we print the error message in the format TeamCity understands:
Console.Out.WriteLine(
"##teamcity[message text='Custom Script failed.' errorDetails='" +
ex.Message + "' status='ERROR']");
Now, I see that the error is displayed in the build log, however, under the build details, we only see [13:00:25]Process exited with code 1, and in the email notification sent to developers that included changes in that build, only that line is sent.
Is it possible to send in the email, and include in the build details the error we actually print to the console?
There is some build script interaction available:
Console.Out.WriteLine(
"##teamcity[buildProblem text='Custom Script failed.' errorDetails='" +
ex.Message + "']");
And complete it with a buildStatus:
Console.Out.WriteLine(
"##teamcity[buildStatus text='{build.status.text} : Environment variable issue.' status='FAILURE']");
You can get more information about building script interaction on the official website:
When you will send the mail, if you have a specific routine which watch the build, you can get information easily using the available api.

Invalid header field value in Go ONLY on kubernetes/CoreOS

I have a Go program that uses aws-sdk-go to talk to dynamodb. Dependencies are vendored. Go version 1.7.1. aws-sdk-go version 1.6.24. The program works as expected in all the following environments:
dev box from shell (Arch Linux)
docker container running on my dev box (Docker 1.13.1)
Ec2 instance from shell (Ubuntu 16.04)
When I run the docker container on kubernetes (same one I tested on my dev box), I get the following error:
2017/03/02 22:30:13 DEBUG ERROR: Request dynamodb/GetItem:
---[ REQUEST DUMP ERROR ]-----------------------------
net/http: invalid header field value "AWS4-HMAC-SHA256 Credential=hidden\n/20170302/us-east-1/dynamodb/aws4_request, SignedHeaders=accept-encoding;content-length;content-type;host;x-amz-date;x-amz-target, Signature=483f56dd0b17d8945d3c2f2044b7f97e531190602f132a4d5f828264b3a2cff2" for key Authorization
-----------------------------------------------------
2017/03/02 22:30:13 DEBUG: Response dynamodb/GetItem Details:
---[ RESPONSE ]--------------------------------------
HTTP/0.0 000 status code 0
Content-Length: 0
Based on:
https://golang.org/src/net/http/transport.go
https://godoc.org/golang.org/x/net/lex/httplex#ValidHeaderFieldValue
It looks like the problem is with the header value validation, yet I am at a loss to understand why it works everywhere except on my k8s cluster. The cluster is composed of Ec2 instances running the latest CoreOS stable ami (CoreOS stable 1235.8.0)
The docker image that works on my dev machine is scratch based. To troubleshoot I created an image based on Ubuntu latest with a separate go program that just does a simple get item from dynamodb. When this image is run on my k8s cluster and the program run from an interactive shell, I get the same errors. I have confirmed I can ping the dynamodb endpoints from this env.
I am having a hard time troubleshooting this issue: am I missing something stupid here? Can someone point me in the right direction or have an idea of what is going on?
remember the "-n" when you do this:
echo -n key | base64
The \n after hidden is certainly invalid. Not sure if it is actually there or somehow got inserted when you were cleansing for posting.
Consider:
package main
import (
"fmt"
"golang.org/x/net/lex/httplex"
)
func main() {
fmt.Println("Is valid (without new line)", httplex.ValidHeaderFieldValue("AWS4-HMAC-SHA256 Credential=hidden/20170302/us-east-1/dynamodb/aws4_request, SignedHeaders=accept-encoding;content-length;content-type;host;x-amz-date;x-amz-target, Signature=483f56dd0b17d8945d3c2f2044b7f97e531190602f132a4d5f828264b3a2cff2"))
fmt.Println("Is valid (with new line)", httplex.ValidHeaderFieldValue("AWS4-HMAC-SHA256 Credential=hidden\n/20170302/us-east-1/dynamodb/aws4_request, SignedHeaders=accept-encoding;content-length;content-type;host;x-amz-date;x-amz-target, Signature=483f56dd0b17d8945d3c2f2044b7f97e531190602f132a4d5f828264b3a2cff2"))
}
One guess would be wherever the real hidden value is getting pulled from (config file etc) mistakenly has the \n in there and it's happily getting pulled into your header, but only in this case.

ADODB.Connection error from Ruby script on Apache server

I have a Ruby script (non-Rails) that connects to a SQL Server database. When run from the command line, it runs fine. When executed via an http request, it generates an error, specifically when opening the DB connection. Something about the combination of the http/SQL methods is failing.
I'm running the script on a machine with: Windows 7 Ultimate (64-bit), Ruby 1.9.3p125, Apache 2.2.11. The database is SQL Server 10.0.4000, hosted on a separate (corporate, internal) server.
The script looks something like this:
#!/Ruby193/bin/ruby
require 'win32ole'
...
$qadb = nil
begin
$qadb = SqlServer.new('192.168.100.249', 'qauser', 'password')
$qadb.open('qadb')
rescue
logRegression("Rescued: Unable to access QADB: #{$!}")
end
The SqlServer class is based on David Mullet's code, found at http://rubyonwindows.blogspot.com/2007/03/ruby-ado-and-sqlserver.html (not copied here for brevity).
From the command line, the DB opens fine and I get an expected result from the script. When I call the script via my internal server (http://qatools/getTask.rb) I get the following error in my log file:
Rescued: Unable to access QADB: failed to create WIN32OLE object from `ADODB.Connection'
HRESULT error code:0x8007007e
The specified module could not be found.
I've considered that I might be missing a DLL. Other research led me to ntwdblib.dll -- I tried downloading a copy and placing it in various folders. I've also considered that I might be facing an Apache configuration issue and/or a security/permissions issue but I haven't found any solutions for those that seem to fit my specific problem.
Any ideas?

gsoap error: SOAP-ENV:Client [no subcode]

I downloaded gsoap 2.8 and went into the samples folder and ran a make. Everything seems to have built fine. I then navigated into the "ssl" folder and ran the sllserver in one xterm and ran sslclient in a second xterm window. (I am running RHEL 6) The server seems to run fine, it says "Bind successful: socket = 4". But when I run the client I receive the following message:
Error -1 fault: SOAP-ENV:Client [no subcode]
"End of file or no input: Operation interrupted or timed out (30 s receive delay) (30 s send delay)"
Detail: [no detail]
I have not modified any of the sample code, so it seems like it should just work. Can anyone please give me some advice as to what I should look at? I am trying to learn how to set up a soap server that uses ssl. (I have a gsoap server running already) I searched all day for an example on the web and as usual, there is not one.
Thank you so much for any help.
You could rebuild this example with compiler switch -DDEBUG to enable message logging (make 'sslclient_CFLAGS = -DWITH_OPENSSL -DWITH_GZIP -DDEBUG'). The TEST.log will tell what went wrong. I suspect it is a network issue with the server address/port that is set by default to "https://localhost:18081".
You could set the timeout parameter: soap.recv_timeout = 60 (for 60 seconds)

Resources