Puppeteer - How to change time input to 24 hour format? - puppeteer

How to change time input to 24-hour format? I used it for testing in Jenkins pipeline, the test misses the am/pm input. My intended user doesn't need am/pm input.
I already change the locale to my country id and restart the Linux server
LANG=id_ID.UTF-8
LANGUAGE=
LC_CTYPE="id_ID.UTF-8"
LC_NUMERIC="id_ID.UTF-8"
LC_TIME="id_ID.UTF-8"
LC_COLLATE="id_ID.UTF-8"
LC_MONETARY="id_ID.UTF-8"
LC_MESSAGES="id_ID.UTF-8"
LC_PAPER="id_ID.UTF-8"
LC_NAME="id_ID.UTF-8"
LC_ADDRESS="id_ID.UTF-8"
LC_TELEPHONE="id_ID.UTF-8"
LC_MEASUREMENT="id_ID.UTF-8"
LC_IDENTIFICATION="id_ID.UTF-8"
LC_ALL=
that doesn't work,
also tried adding lang args to launch --window-size=${width},${height} --lang=id
doesn't work too.
It occurs when puppeteer render input with the type time
<input type="time" name="time" value="" class="form-control">
In my local computer, it renders
in the Linux Jenkins server, I the screenshot renders

I see in document type=time , 12 or 24-hour format depending on operating system locale.
Check locale:
$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Change locale:
$ sudo update-locale LANG=LANG=en_IN.UTF-8 LANGUAGE
OR
$ sudo localectl set-locale LANG=en_IN.UTF-8
Do you try to change locale your server same with your local? Hope it work :)
Edited: If you don't want time format depending on the locale of the system, you can follow this post (using timepicker.js)

Related

Configure Safenet Luna EFT HSM to allow ISO-0 to ISO-1 pin translation

As the title states I need to be able to convert an ISO-0 formatted encrypted pin block to ISO-1 format using a Safenet(Gemalto) Luna EFT. I am connecting over TCP/IP and sending commands formatted per programmer's guide.
I am using PIN-TRANSLATE-2 EE0602 and getting back a 06 error code indicating to me that it won't allow the conversion from ISO 0 to 1.
I know this can somehow be enabled via HSM configuration. Can someone please show me how?
Please refer the product documentation:
Luna EFT Administration Console > Payment Configuration > PIN Security > PIN Conversion

AWS SSM Parameter Store: How can I edit multi-line "SecureString" values using the console?

Currently, I use a single SSM parameter to store a set of properties separated by newlines, like this:
property1=value1
property2=value2
property3=value3
(I am aware of the 4K size limit, it's fine.)
This works well, for normal String type parameters that store non-sensitive information like environment configuration, but I'd also like to do similar for secrets using the SecureString parameter type.
The problem is that I can't edit the parameter value in the console because it's using a HTML input field of type="password" that doesn't handle newlines.
The multi-line value works fine with the actual parameter store backend - I can set a value with multiple lines with the SSM API no problem and they can be read with the EC2 CLI properly too.
But I can't edit them using the console. This is a problem because the whole point of using a SecureString parameter is that I intend the only place to edit/view these secrets to be via the console (so that permissions are controlled and access is audited).
There's a few infrastructure workarounds I could implement (one parameter for each secret, store the secrets on S3 or other secret storing service, etc.) but they all have drawbacks - I'm just trying to find out if there's a way around this using the console?
Is there any way I can work around this and use the console to edit multi-line SecureString parameters?
Any kind of browser workaround or hack that I might be able to use to tell the browser to use a textarea instead of a "password" type field?
I'm using Chrome, but I'd be happy to work around this by using another browser or something (editing the secrets is pretty rare, and viewing multi-line values in the console works fine).
EDIT
After posting this question, AWS notified me there was a whole new "AWS Systems Manager" UI, but it still has the same problem - I tried the below browser hacks on this new UI, but no luck.
Failed browser hack attempt 1: I tried opening the browser console, running document.getElementById("Value").value = "value1\nvalue2" and then clicking the save button, which set the value I injectec, but the newline was filtered out.
Failed browser hack attempt 2: I tried using the browser instpector to change the element to a TextArea and then typed in two lines of input and clicked save, but that didn't set the value at all.
From https://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#cli-using-param-file, I learned you can pass a file as parameter to the --value argument. So if your file is called secrets.properties, you can do this:
aws ssm put-parameter --type SecureString --name secrets --value file://secrets.properties
I found a way to do it, but it's too much effort and too weird - if anyone can find a simpler way, I will mark that as the answer.
The hacky workaround is to install the "Tamper Chrome" extension + app, then capture the XHR request as the browser sends it and edit the new lines into the JSON.
Blech. Plus "Tamper Chrome" is pretty awful, I don't want to run it on my machine.
This might be better to use the new secrets manager that was launched recently. The interface for it is very close to parameter store but it has better support for multiple parameters in one place.
I wonder if the change in the console was due to the expected release of the service since they have a pricing model around secrets whereas parameter store is free
In the end, I decided the answer to this question is "don't do that". Not that I would've wanted to hear that when I was trying to make it work.
You should use a separate SSM param per secret for these reasons:
ability to grant permissions at fine grained level; e.g. you have an API password for calling your service, and a DB password for the service talk to a DB - if you store them in the same secret you couldn't only grant access to the API password.
ability to track key access separately - the SSM access logs can only tell you that the target machine/user accessed the SSM param at that time, it won't be able to tell you which secret was accessed
ability to use separate KMS keys to encrypt
Just watch out for the fact that you can only request a max of 10 SSM params at a time.
if you want, you can try with my app https://github.com/ledongthuc/awssecretsmanagerui
I try to create it to easier to update multi-line values and binary easier. Hope it's helpful with your case.

JSON::XS under mod_perl fails with POST requests

I am using the default install of Apache and mod_perl on Ubuntu 16.04.1 LTS, I also have reproduced this with the default JSON::XS and I updated to the latest from CPAN JSON-XS-3.02.
The code below works in all cases if I am not using mod_perl.
The script and html below work when using perl via mod_cgi with both POST and GET requests.
If however I am using mod_perl and I use a POST (as in the html provided) it fails, "Hello" does not print, and I get the following error in my apache log file.
Usage: JSON::XS::new(klass).
If I pass the same parameter(s) via a GET method, the script works fine.
test2.pl
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use JSON::XS;
my $q = new CGI();
print $q->header(-type => 'text/plain');
my $action = $q->param('a');
my $json_str = '{"foo":"bar"}';
my $pscalar = JSON::XS->new->utf8->decode($json_str);
print "Hello";
exit 1;
HTML to call the above (named test2.pl on the server)
<html>
<body>
<form action="test2.pl" method="POST">
<input type="text" name="a"/>
<button type="submit">
</form>
</body>
</html>
OK So this was a rather wild goose chase, analyzing apache core dumps and stack traces, fixing bugs that weren't really there... Long story short.
I was trying to add an include directory to my perl by using
PerlSwitches -I/usr/local/lib/site_perl/my_new_directory
As part of that I added
PerlOptions +Parent so that I would get a new interpreter for each virtual host so my -I was effective for only one virtual host at a time.
I had added those flags before I enabled mod_perl, so when I enabled mod_perl, it just never worked.
By removing the PerlOptions +Parent things started working as expected.
As a side note, it appears +Parent makes things wonky in genral.

wget not completely processing the http call

Here is a wget command that executes a HTML / PHP stack report suite that is hosted by a third party - we don't have control over the PHP or HTML page
wget --no-check-certificate --http-user=/myacc --http-password=mypass -O /tmp/myoutput.csv "https://myserver.mydomain.com/mymodule.php?myrepcode=9999&action=exportcsv&admin=myappuserid&password=myappuserpass&startdate=2011-01-16&enddate=2011-01-16&reportby=mypreferredview"
All the elements are working perfectly:
--http-user / --http-pass as offered by a browsers standard popup for username and password prompt
-O /tmp/myoutput.csv - the output file of interest
https://myserver.mydomain.com/mymodule.php?myrepcode=9999&action=exportcsv&admin=myappuserid&password=myappuserpass&startdate=2011-01-16&enddate=2011-01-16&reportby=mypreferredview"
The file generated on the fly by the parameters
myrepcode=9999 - a reference to the report in question
action=exportcsv internally written in the function
admin=myappuserid the third party operats SSL to access the site - then internal username and password stored in a database to access the functions of the site)
password=myappuserpass
startdate=2011-01-16 this and end data are parameters specific to the report 9999
enddate=2011-01-16
reportby=mypreferredview This is an option in the report that facilitates different levels of detail or aggregation
The problem is that the reportby parameter is a radio button selection in a list of 5 selections (sure I enough the default is highest level of aggregation , I want the last one which is the most detailed)
Here is a sample of the HTML page code for the options of reportby
The tags in the HTML are not whitelisted - so I will send the sample if requested
<td>View by</td>
<td>
<input class="naf-radio" name="reportby" id="reportby[thedefault]" value="thedefault" type="radio">The Default
<input class="naf-radio" name="reportby" id="reportby[myleastpreferred]" value="myleastpreferred" type="radio">My Least Preferred
<input class="naf-radio" name="reportby" id="reportby[mysecondleastpreferred]" value="mysecondleastpreferred" type="radio">My Second Least Preferred
<input class="naf-radio" name="reportby" id="reportby[mythirdleastpreferred]" value="mythirdleastpreferred" type="radio">My Third Least Preferred
<input class="naf-radio" name="reportby" id="reportby[mypreferred]" value="mypreferred" type="radio">My Preferred
</td>
No matter which of the reportby items I select in the wget statement - thedefault is always executed.
Questions
1) Has anyone come across this notation in HTML (id=inputname[inputelement])
I spoke to a senior web developer and he has never seen this notation for inputs (id=inputname[inputelement]) - and w3schools do not appear familiar with this either based on an extensive search
2) Can a wget command select a none default radio item when executing the command ?
This probably will be initially received with a "Use CURL" response- however the wget approach works very well in the limited environment I am operating in - particularly as I need to download 10000 of these such items.
Thanks ahead of response
A radio button is just another form element and can be passed through the querystring usually. Some applications will demand that parameters are passed as POST data but this isn't that common in my experience.
What you'll need to do is find the name of the radio buttonand the value that is on the desired option. You then just add &name=value to your current url and it should act like selecting that radio button.
The notation id=inputname[inputelement] could exist in javascript or similar languages but not in HTML. In HTML its just name=value type of declarations in urls (and attribtues and other things). In this case I would assume that this string was meant to have been interpreted in whatever code generated the HTML rather than rendered to screen.
Also you need to make sure you urlencode any values that you are putting in the url to make sure they don't contain any illegal characters (eg an & or = will confuse it completely).
If the querystring method doesn't work then wget has a --post-data switch that allows you to specify data to be posted whcih is what a form would do. If you use --post-data=reportby=mypreferred I hope you should have more success with that.
If this still fails then I would use some tool to view your wget request as well as your request through a browser and compare the headers and data to see what is different about them. one such tool for this is fiddler (http://www.fiddler2.com/fiddler2/) though I'm sure many others exist.

Last Modified Date of a file on a web site

Is there a way to get the Last-Modified-Date of a file on a Web Site?
i.e. Here is an example file I have out there:
http://www.ymcadetroit.org/atf/cf/%7B2101903E-A11A-4532-A64D-9D823368A605%7D/Birmingham_Youth_Sports_Parent_Manual.pdf
Go to the website you want to know about, wait for it to fully load, then go to the address bar and write this:
javascript:alert(document.lastModified)
You'll get a popup that says when it was last modified.
The HTTP intends the Last-Modified header field to declare the last modification date. But the server needs to know that date.
On static files whose content is sent directly to the client and not interpreted otherwise by the server (e.g. .html, .css, .js) it uses the last modified date of that file. But on files that generated content dynamically (PHP, Python, etc.) the script needs to specify that information itself. But unfortunatly many scripts don’t to that.
So if a Last-Modified header field is present, you can use that information. But if not, you cannot determin the last modification date.
Here is some C# code to do it:
public DateTime GetLastModifyTime(string url)
{
WebRequest request = WebRequest.Create(url);
request.Credentials = CredentialCache.DefaultNetworkCredentials;
request.Method = "HEAD";
using (WebResponse response = request.GetResponse())
{
string lastModifyString = response.Headers.Get("Last-Modified");
DateTime remoteTime;
if (DateTime.TryParse(lastModifyString, out remoteTime))
{
return remoteTime;
}
return DateTime.MinValue;
}
}
I realize this question is 4 years old, but a search of the web proved that satisfactory answers remain rare. Peter's answer is part of the solution. When I had the same problem to solve, that got me started. But the rest of the solution...
As he said, the web server must be configured to send the last-modified date ... so how do you configure the web server?
Assuming you have the necessary level of control, you first need to enable server side includes. There are several ways to do this - one of which is the "xbithack". A good reference is http://httpd.apache.org/docs/current/howto/ssi.html.
Assuming you've done this, you need to set the execute bit on any html file that needs to have server-side includes parsed. This can be done at the command line of a UNIX-like system: chmod u+x file.html or on the Mac using get-info (command-I) on the file.
This leaves the snippet to actually put in your file, which looks like this:
This document last modified <!--#flastmod file="index.html" -->
Since I found many, many recommendations that didn't include this, and simply used the javascript document.lastModified, I suspect that some servers give you what you want with the javascript version, whereas some (including the one hosting our stuff) don't.
To obtain the last modified date from client side, you can access the HTML DOM using the lastModified property using JavaScript.
The lastModified property grabs the information from the head portion sent with all web requests. The value can be manually set by developers on the web-server side of things so it may not reflect the actual last modified date of the file responsible for delivering the content.
Example
<!DOCTYPE html>
<html>
<body>
<b>document.lastModified : </b>
<script>document.write( document.lastModified );</script>
</body>
</html>
The specific command in JavaScript that retrieves this is document.lastModified and can easily be converted into a Date object as follows :
var x = new Date(document.lastModified);
More information can be found on the site I used as a reference w3 schools : HTML DOM lastModified Property
I believe the web server must be configured to send the last-modified date in an HTTP-header, this is certainly one way. Check out section 14.29 Last-Modified of this document:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
You can do the following to get Last-Modified:
https://superuser.com/a/991895
Using curl:
curl -s -v -X HEAD http://foo.com/bar/baz.pdf 2>&1 | grep '^< Last-Modified:'
Using wget:
wget --server-response --spider http://example.com/bar/example.pdf 2>&1 | grep -i Last-Modified
With just plain HTML, no you cannot.
You can with PHP, or ASP, or any other server side language.
I'm not an expert in headers, but believe you are looking for this:
There is a way to check the date when a file was modified:
View HTTP headers in Google Chrome?
Check in there (Chrome's Developer Tools / Network / Selected File / Headers) the "If-Modified-Since" variable.
Until now this has helped me to achieve what you are asking, get a file's modification date.
In php:
print getlastmod();
print gmdate('D, d M Y H:i:s', getlastmod());