Fork me on GitHub
#babashka
<
2020-11-03
>
borkdude08:11:54

@lukaszkorecki I can add it if you want, it takes about 80kb extra. Can you explain the use case a bit?

borkdude10:11:20

Btw, I now fixed this example on master:

$ ./bb -e "(take 4 (iterator-seq (.iterator (.doubles (java.util.Random.)))))"
(0.11018020853952415 0.8538439232524406 0.24374736204535452 0.975224420988415)

lukasz14:11:37

@borkdude I have reimplemented RabbitMQ's password hashing algo, at one point it requires 4 bytes of a random salt, so out of habit I always reach for SecureRandom but in this case good old j.u.Random will suffice. I guess it comes from the fact that MessageDigest is included. Babashka/SCI is so good I keep forgetting it's not "full" Clojure :-)

lukasz14:11:36

I suppose if it only adds 80kb, it would be worth including, since it adds that "parity" to MessageDigest

lukasz14:11:51

but, it's not like it's critically needed

borkdude14:11:09

MessageDigest is included to calculate sha-256 hashes, etc, which is quite common in scripting

lukasz14:11:32

yep, exactly what I'm doing right now

borkdude14:11:51

How does j.s.R relate to MessageDigest?

lukasz14:11:48

It doesn't really, apart from both being a part of java.security. package. It only came up in my use case - I needed both, being used to having both in regular Clojure and implementing various cryptography stuff (which I'm surprised how much I had to do this year 🤔 )

dharrigan14:11:47

If I'm also not mistaken, UUID generation using Java uses the SecureRandom class

borkdude14:11:06

OK, but we already have that:

borkdude14:11:09

$ bb '(java.util.UUID/randomUUID)'
#uuid "705b0ba1-d637-45aa-ad35-4aba31cbd9e2"

borkdude14:11:03

fwiw, this entire library works with bb: https://github.com/clojure/data.generators

borkdude14:11:59

I guess you could bind *rnd* to a j.s.R instance for more secure randomness?

lukasz14:11:32

yeah, could work. Again: it's not incredibly painful to not have SecureRandom, I naively assumed it's already in BB

lukasz14:11:55

PEKBAC etc etc

borkdude14:11:26

no problem. if the need arises I would add it, if it would enable access to some interesting library for example

borkdude15:11:49

btw, @lukaszkorecki are you still considering writing an AWS pod? I noticed https://github.com/BrunoBonacci/graalvm-clojure/tree/master/amazonica-s3 is graal compatible. Together with the new support for transit in pods it might feasible, maybe using some code generation.

lukasz15:11:06

Good timing - I have just kicked off the work which will involve this. At this point I'm considering using babashka.process and AWS CLI v2 as we are using AWS SSO for credentials, and none of the AWS SDKs (Java, Go etc) support that right now. Also, that gives access to all AWS services in a programatic way - my understanding is that with amazonica and the AWS SDK we had to pick and choose what gets included when compiling using native-image, right?

borkdude15:11:59

That's correct. The way I usually accomplish this is by putting stuff in a map and looking it up dynamically. This ensures GraalVM will hold on to it. https://github.com/babashka/pod-babashka-lanterna/blob/main/src/pod/babashka/lanterna.clj#L106

lukasz15:11:48

So yeah, going with aws cli might be more flexible since services you might need to interact with might not be known (we need ECS, S3, SecretsManager, SSM and couple of more, some people might need S3 and DynamoDB only etc).

borkdude15:11:29

yeah, shelling out to a CLI is a good way to get stuff done

lukasz15:11:57

The good thing is that the CLI is somewhat structured in the way you call it, so I think it can have a sane API in Clojure in terms of the interface. Something like (aws :ec2 :describe-instances {:instance-ids ["a" "b"] }) We will see.

lukasz15:11:12

By the way - the post about monitoring ECS with babashka will be published soon :-)

borkdude15:11:41

@lukaszkorecki :-) Here's an example of a lib that shells out to psql: https://github.com/borkdude/babashka/blob/master/doc/libraries.md#clj-psql Might be cool to publish somewhere at some point.

borkdude15:11:12

I've heard that the AWS cli sometimes makes breaking changes, not sure how bad those are? Is that what you're referring to with v2?

lukasz15:11:22

Yep, I'm planning to open source our RMQ monitoring + Docker setup - all tooling is based on BB

lukasz15:11:46

the AWS CLI pod is speculative atm, I'll be digging into it properly in a week or so

lukasz15:11:21

V2 broke in the sense that it went straight into python3 (but it vendors) it and it has features that v1 doesn't (SSO integration for example)

lukasz15:11:39

so if you were installing the CLI via python's pip, you were going to have a bad time

borkdude17:11:02

Wow.... matchete, a library like meander, works with babashka:

$ rlwrap bb -cp "$(clojure -Spath -Sdeps '{:deps {io.xapix/matchete {:mvn/version "1.2.0"}}}')"
user=> (require '[matchete.core :as mc])
nil
user=> (mc/matches '{?k 1} {:x 1 :y 1})"
({?k :y} {?k :x})