Concourse CI windows/strict mime type checking - concourse

When running concourse ci v3.3.2 locally on Windows I get these errors:
Refused to execute script from
'http://192.168.178.29:8080/public/index.js?id=932c553753eec4ef375e1c17f4b28c10' because its MIME type ('text/plain') is not executable, and strict
MIME type checking is enabled.
192.168.178.29/:1 Refused to execute script from 'http://192.168.178.29:8080/public/d3.v355.min.js?id=5936da7688d010c60aaf8374f90fcc2b' because its MIME type ('text/plain') is not executable, and strict
MIME type checking is enabled.
192.168.178.29/:1 Refused to execute script from 'http://192.168.178.29:8080/public/graph.js?id=3e2a3f561ec6c52216e80266ef0212d2' because its MIME type ('text/plain') is not executable, and strict
MIME type checking is enabled.
192.168.178.29/:1 Refused to execute script from 'http://192.168.178.29:8080/public/jquery-2.1.1.min.js?id=e40ec2161fe7993196f23c8a07346306'
because its MIME type ('text/plain') is not executable, and strict
MIME type checking is enabled.
192.168.178.29/:1 Refused to execute script from 'http://192.168.178.29:8080/public/concourse.js?id=b4688d002041187f6c55f6e8699442ba' because its MIME type ('text/plain') is not executable, and strict
MIME type checking is enabled. (index):1 Refused to execute script
from
'http://192.168.178.29:8080/public/elm.min.js?id=d38f054604f3aaf5cd4eb0616b3cb3ef' because its MIME type ('text/plain') is not executable, and strict
MIME type checking is enabled. (index):20 Uncaught ReferenceError: Elm
is not defined
at (index):20
It's probably something obvious but couldn't find anything on google/stack overflow for these errors in combination with Concourse

Related

Set MIME type for ".mjs" file loaded in WebView of vscode extension

I am working on a vscode extension that displays a webpage inside a WebView.
The webpage has a <script> tag with type="module" and is sourced through vscode-resource protocol. That JS module fails to load inside WebView with the following error:
"Failed to load module script: The server responded with a non-JavaScript MIME type of "application/unknown". Strict MIME type checking is enforced for module scripts per HTML spec."
How can I set the MIME type for that resource?
You need to set the server to send .mjs files as JavaScript MIME type
text/javascript

Cannot load webUI correctly

I could get the page on localhost:8089 but not the style.css .These are the results from firefox and chrome:
Firefox:
GET http://localhost:8089/static/style.css?v=1.0 [HTTP/1.1 200 OK 17ms]
The stylesheet http://localhost:8089/static/style.css?v=1.0 was not loaded because its MIME type, “application/x-css”, is not “text/css”.
Chrome:
localhost/:5 Resource interpreted as Stylesheet but transferred with MIME type application/x-css: "http://localhost:8089/static/style.css?v=1.0".
How to make the web normal? pls help.
Is it possible you are encountering the same problem mentioned here?
https://community.grafana.com/t/grafana-start-but-stylesheets-not-displayed/3250/11
Specifically check your registry (https://gogs.io/docs/intro/troubleshooting#windows):
Error: Resource interpreted as Stylesheet but transferred with MIME type application/x-css
Causes: wrong value in the Windows registry
Solution: Find .css in HKEY_CLASSES_ROOT in registry and change its Content Type to text/css.

No matching mac found: client hmac-sha2-512-etm#openssh.com,hmac-sha2-256-etm#openssh.com,hmac-sha2-512,hmac-sha2-256 server hmac-sha1

I am getting below error while running my script, I am on AIX
Reading configuration data /ecmsq1vg1/home1/aradmin/.ssh/config
Reading configuration data /etc/ssh_config
Connecting to www.mftcatapp.firstdataclients.com, port 22.
Remote version string: SSH-2.0-Sun_SSH_1.1.8
Remote protocol version 2.0, remote software version Sun_SSH_1.1.8
Net::SSH::Perl Version 2.14, protocol version 2.0.
No compat match: Sun_SSH_1.1.8.
Connection established.
Sent key-exchange init (KEXINIT), waiting for response.
No matching mac found: client hmac-sha2-512-etm#openssh.com,hmac-sha2-256-etm#openssh.com,hmac-sha2-512,hmac-sha2-256 server hmac-sha1 at /apps/perl/lib/site_perl/5.18.1/aix-thread-multi/Net/SSH/Perl/SSH2.pm line 273
Can anyone help me out why i am facing the above error?
perldoc Net::SSH::Perl:
Integrity checking is performed by the hmac-sha2-256, hmac-sha2-512, hmac-sha2-256-etm#openssh.com, or hmac-sha2-512-etm#openssh.com algorithms. The deprecated hmac-sha1 or hmac-md5 algorithms are available but not enabled by default. Many older SSH server installations still use hmac-sha1 as the main accepted MAC algorithm. To enable this, use the following options parameter:
options => [ "MACs +hmac-sha1" ]
So either configure your server not to use hmac-sha1 for integrity checking or tell your script to accept hmac-sha1.

LWP Won't Run in CGI Script

I have a CGI script to load publications from BibBase:
#!/usr/bin/perl
use LWP::UserAgent;
my $url = 'https://bibbase.org/show?bib=http://www.example.com/pubs.bib';
my $ua = LWP::UserAgent->new;
my $can_accept = HTTP::Message::decodable;
my $response = $ua->get($url, 'Accept-Encoding' => $can_accept);
print "Content-type: text/html\n\n";
print $response->decoded_content;
(This is copied from BibBase with the exception that the URL is hard-coded.)
I have three webservers running RHEL7 and Apache 2.4 that are configured the same way by Puppet. On all three I can run the script on the command line and get the expected results:
[root#server1 cgi-bin]# ./bibbase_proxy2.cgi | head
Content-type: text/html
<img src="//bibbase.org/img/ajax-loader.gif" id="spinner" style="display: none;" alt="Loading.." />
<div id="bibbase">
<script type="text/javascript">
var bibbase = {
params: {"bib":"http://www.example.com/pubs.bib","host":"bibbase.org"},
When I try to run the script with CGI, I get three different results:
Server1
Unrecognised protocol tcp at /usr/share/perl5/LWP/Protocol/http.pm line 31.
Server2
Can't connect to bibbase.org:443 System error at /usr/share/perl5/LWP/Protocol/http.pm line 51.
Server3
No http output and the error log says AH01215: Out of memory!.
I can't find anything different between the three servers and I can't figure out why the script works fine on the command line and doesn't work when run as a CGI.
I have selinux in permissive mode and it is logging the outgoing request, so I know the script gets that far:
type=AVC msg=audit(1532465859.921:331235): avc: denied { name_connect } for pid=161178 comm="perl" dest=80 scontext=system_u:system_r:httpd_sys_script_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket
For testing, I have set selinux to disabled and restarted the server.
SE-Linux denied the TCP connection.
avc: denied { name_connect }
The default access controls for networking by SELinux are based on the labels assigned to TCP and UDP ports and sockets. For instance, the TCP port 80 is labeled with http_port_t (and class tcp_socket). Access towards this port is then governed through SELinux access controls, such as name_connect and name_bind.
When an application is connecting to a port, the name_connect permission is checked. However, when an application binds to the port, the name_bind permission is checked.
Permissive mode or not, Perl is acting like it was denied a TCP connection. Unrecognised protocol tcp means getprotobyname("tcp") failed inside IO::Socket::IP. That's very, very unusual. One of the ways that can happen is via exactly that SELinux denial.
I'm no SELinux expert, but according to RedHat and Gentoo some SELinux aware applications will ignore the global permissive setting and go it alone. RHEL 7 Apache appears to be one of them. It appears to have its own domain which must be set permissive.
On all three I can run the script on the command line and get the expected results:
There's two reasons for that, and they both have to do with users.
When you run the program you're running as your own user with your own configuration, permissions, and environment variables. In fact, you ran it as root which usually bypasses restrictions. When it runs on the server it runs as a different user, probably the web server user with severe restrictions.
In order to do a realistic test, you need to run it as the same user the web server will. You can use sudo -u for this. For example, if the user is apache...
sudo -u apache ./bibbase_proxy2.cgi
BTW Do not test software as root! Not only is it not going to give you sensible results, but if there's a bug in the software there are no safeguards preventing it from wrecking your system.
The second problem is #!/usr/bin/env perl. That means to run whatever perl is in your PATH. PATH will be different for different users. Running ./bibbase_proxy2.cgi may run with one Perl on the command line and a different one via the web server.
In a server environment, use a hard coded path to Perl like #!/usr/bin/perl.
We tested by rewriting the same script in Python and PHP. Both of them showed error which pointed us in the right direction.
Python urllib2 produced the error
<class 'urllib2.URLError'>: <urlopen error [Errno 16] Device or resource busy>
args = (error(16, 'Device or resource busy'),)
errno = None
filename = None
message = ''
reason = error(16, 'Device or resource busy')
strerror = None
PHP (run as CGI) wouldn't even start:
[Wed Jul 25 15:24:52.988582 2018] [cgi:error] [pid 10369] [client 172.28.6.200:44387] AH01215: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/curl.so' - libssh2.so.1: failed to map segment from shared object: Cannot allocate memory in Unknown on line 0
[Wed Jul 25 15:24:52.988980 2018] [cgi:error] [pid 10369] [client 172.28.6.200:44387] AH01215: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/dba.so' - libtokyocabinet.so.9: failed to map segment from shared object: Cannot allocate memory in Unknown on line 0
---- Similar lines for all extensions. ----
It appears that RLimitMEM blocks access to shared memory and that is required for opening sockets. I can't find any documentation, but removing that line makes it work.

Request is missing required `Host` header error in Scala Play 2.6.7 Akka

In production mode, the server failed to start and keeps print the following log. I cannot access the web pages. But the code runs fine in development mode. How to resolve the problem?
2017-11-23T10:04:07+08 [INFO] from play.core.server.AkkaHttpServer [main]
Listening for HTTP on /0:0:0:0:0:0:0:0:9000
2017-11-23T10:04:08+08 [WARN] from akka.actor.ActorSystemImpl [application-akka.actor.default-dispatcher-4]
Illegal request, responding with status '400 Bad Request': Request is
missing required `Host` header: Cannot establish effective URI of request
to `/`, request has a relative URI and is missing a `Host` header;
consider setting `akka.http.server.default-host-header`
2017-11-23T10:04:08+08 [WARN] from akka.actor.ActorSystemImpl [application-akka.actor.default-dispatcher-3]
Illegal request, responding with status '400 Bad Request': Request is
missing required `Host` header: Cannot establish effective URI of request
to `/`, request has a relative URI and is missing a `Host` header;
consider setting `akka.http.server.default-host-header`
the haproxy server health check did not send the Host header to the server
haproxy httpchk should be modified as this
option httpchk GET / HTTP/1.1\r\nHost:localhost
Depending on your HAProxy version the supported syntax might vary. This appears to be working with HAProxy 2.0.x
option httpchk GET /health
http-check send hdr Host localhost
Make sure to check the documentation for you version.