WEBVTT

00:00:00.001 --> 00:00:04.680
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.

00:00:04.680 --> 00:00:13.020
This is episode 276, recorded March 22nd, 2022. So many twos. I'm Michael Kennedy.

00:00:13.020 --> 00:00:14.000
And I'm Brian Okken.

00:00:14.000 --> 00:00:15.140
And I'm Ian Hellen.

00:00:15.140 --> 00:00:18.160
Hey, Ian. Welcome to the show. It's great to have you here.

00:00:18.160 --> 00:00:23.300
Thank you very much. I've listened to the show a lot and feel very privileged to appear on it.

00:00:23.300 --> 00:00:29.040
It's our privilege to have you here. Thank you so much for listening. And I know you got some

00:00:29.040 --> 00:00:33.700
cool stuff to share. So we're looking forward to hearing about that. Also, I do want to say

00:00:33.700 --> 00:00:39.280
thank you to Fusion Auth for sponsoring the show. I'll tell you more about them later.

00:00:39.280 --> 00:00:42.780
Before we get into the topics, Ian, tell people a quick bit about yourself.

00:00:42.780 --> 00:00:48.160
Sure. I'm a developer in Microsoft, the Microsoft Threat Intelligence Center.

00:00:48.160 --> 00:00:52.580
Been with Microsoft for quite a long time. Only relatively recently, like four years so ago,

00:00:52.580 --> 00:00:58.000
got into Python coding with Jupyter Notebooks. So I work on Jupyter Notebooks for the Microsoft

00:00:58.080 --> 00:01:05.200
Sentinel project and own a modest open source package that we'll call MysticPy, which we'll

00:01:05.200 --> 00:01:07.500
cover a little bit later. Takes most of my time.

00:01:07.500 --> 00:01:14.320
Fantastic. The whole cybersecurity threat detection stuff, it's very interesting. There's a lot of

00:01:14.320 --> 00:01:17.520
innovation there, but it's also, it's a challenging area to be working.

00:01:17.520 --> 00:01:20.020
Yep. Yep. We're never sure of stuff to do.

00:01:20.020 --> 00:01:25.480
Certainly. I'm sure you're not. Well, Brian, how about you kick us off here?

00:01:25.640 --> 00:01:30.980
Well, so I'm going to start off with a problem. So I had a problem and I have a cool solution for it.

00:01:30.980 --> 00:01:39.140
So my problem is on test and code, I've got titles and I want to end a show on it. It's MP3 file,

00:01:39.140 --> 00:01:44.960
but I want to create a show notes, automated show notes or not show notes, a transcript.

00:01:45.340 --> 00:01:50.500
So one of the problems, there's a lot of problems in doing this, trying to automate it, but one of them

00:01:50.500 --> 00:01:57.940
is the title. I want to turn that into something that's a little bit, so something like, you know,

00:01:57.940 --> 00:02:03.320
it's got normal English and capitalization and all sorts of spaces and stuff. I want to turn that into

00:02:03.320 --> 00:02:09.340
things that URLs hate. Yeah. I want to turn that into a URL. And, and one of the problem,

00:02:09.340 --> 00:02:13.980
one of the things is getting rid of stop words. So there's a bunch of stuff like lower casing.

00:02:13.980 --> 00:02:19.360
I can do that easy, but getting rid of stop words was a little hard. So I ran across this,

00:02:19.360 --> 00:02:28.520
this thing called gen sim parsing, pre processing thing. So pre processing. So gen sim is a larger sort

00:02:28.520 --> 00:02:36.580
of beast. It's a, it's a used for machine or machine learning and stuff to generate models. But I am,

00:02:36.580 --> 00:02:41.740
I'm just really using one little piece of it, the pre processing part. And it's, it's really pretty

00:02:41.740 --> 00:02:47.680
cool. I was looking, I actually found this article first. There was an article called removing stop

00:02:47.680 --> 00:02:55.780
words from strings in Python. And it has, it has a discussion of NLTK and gen sim and spaCy. I tried all

00:02:55.780 --> 00:03:02.940
of them out actually. And the one that really stuck best for me is a using, talked about using

00:03:02.940 --> 00:03:09.120
remove stop words is exactly what I wanted right from, from gen sim. So I went ahead and tried that

00:03:09.120 --> 00:03:15.120
and it worked really well, but I'm like, wait, I'm pulling this is in from the pre processing library.

00:03:15.120 --> 00:03:22.160
I wonder what's what else is in there. And there's all sorts of really cool stuff in here. there's a

00:03:22.160 --> 00:03:27.220
lower lowercase to Unicode. It turns it both into lowercase and in Unicode. That's pretty neat.

00:03:27.220 --> 00:03:33.620
Don't think I need it, but that's neat. but then there was one that was, pre, I thought

00:03:33.620 --> 00:03:38.920
maybe this is exactly what I want is, something called pre-process string. And it has a whole bunch

00:03:38.920 --> 00:03:45.160
of filters built into it. Oh, nice. Like strip strip. Yeah. Strip white space, strip punctuation. I love it.

00:03:45.320 --> 00:03:49.780
Yeah. And take away multiple, after it strips punctuation, like you're going to have,

00:03:49.780 --> 00:03:56.080
if I go back, I had a slash in my title for one of the episodes. If it takes that out, I'm going to

00:03:56.080 --> 00:04:01.780
have a space before and a space after. So I want to remove those. So it'll strip multiple white space

00:04:01.780 --> 00:04:07.100
strips out numerics. Cause I probably don't want numbers in there. and then remove stop words.

00:04:07.100 --> 00:04:13.560
The one thing I don't want that I'll have to like, customize how I'm calling this is a stem text.

00:04:13.560 --> 00:04:18.500
So stem text, I didn't, I don't know what that did without playing with it, but what it does is it

00:04:18.500 --> 00:04:23.800
would take things like twisted and turning it, turn it into twist. That's, that's really not right.

00:04:23.800 --> 00:04:26.920
So you definitely don't want that. I don't want that. I don't mess it up, but I think I want

00:04:26.920 --> 00:04:32.660
everything else. So, this gen SIM, library has, you know, if you're doing machine learning,

00:04:32.660 --> 00:04:39.800
coming up with models, I think this is a great, tool to look into, but if it's actually,

00:04:39.800 --> 00:04:45.740
I'm going to use it just for, removing to create these titles for, for, you know, my podcast,

00:04:45.740 --> 00:04:51.960
but the, I think it, it feels a little weird. It feels like I'm using this really big hammer to do

00:04:51.960 --> 00:04:57.580
this little tiny problem. I guess I'm okay with it, but you know, do you have any other ideas

00:04:57.580 --> 00:05:04.600
where it could use or, well, I didn't know about this. So I wrote my own. Okay. And it's, it's,

00:05:04.600 --> 00:05:08.960
it's kind of janky. Like it's a little bit, a little bit recursive iterative. It's like,

00:05:08.960 --> 00:05:14.040
we'll take away all the punctuation. Now turn all of your white spaces into single white spaces.

00:05:14.040 --> 00:05:18.860
Cause there might've been, you know, dot space. So now you've got two white spaces, but you've got to

00:05:18.860 --> 00:05:22.800
take away, you know, there's like a bunch of weird steps and then, then put it back. This looks

00:05:22.800 --> 00:05:27.380
cleaner. It is a dependency, but it does look cleaner. I like this. I think it's, I'm glad I

00:05:27.380 --> 00:05:32.200
know about it. Ian, what do you think? Is it a huge thing? I mean, dependency, but, I always

00:05:32.200 --> 00:05:37.660
think of like ML like stuff, but this is like just the pre-processing, right? Well, I'm actually pulling

00:05:37.660 --> 00:05:42.980
in all of GenSim to get this. I don't know if I can pull in little bits, but, it's, it's not

00:05:42.980 --> 00:05:48.760
really part of my application that I'm shipping. It's just a tool that I'm using on my laptop. So I,

00:05:49.080 --> 00:05:53.220
I guess downloading it once doesn't really bother me too much, even if it's a big thing.

00:05:53.220 --> 00:05:56.660
But cool. Yeah. I was thinking, yeah, that's a good, that's a good point. If it's running

00:05:56.660 --> 00:06:00.840
local, it's like a dev dependency, who cares? Right. It's like worrying about how big pytest

00:06:00.840 --> 00:06:05.440
is. Like it doesn't really matter. And I'm not, well, I kind of get care about that. Cause

00:06:05.440 --> 00:06:10.160
CI is going to pull it in all the time for pytest, but. Yeah, but they got fast networks.

00:06:10.160 --> 00:06:16.600
It's not your bandwidth. It'll be all right. One of the things that struck me about this

00:06:16.600 --> 00:06:21.780
that made me think of your situation is like that lowercase to Unicode in so many

00:06:21.780 --> 00:06:27.440
times in the security space. It's about like, you're checking for this representation, but what

00:06:27.440 --> 00:06:31.300
if there's another representation that means the same thing? Like you don't say go to this

00:06:31.300 --> 00:06:35.860
directory. You say go dot, dot. And then over there, you know, those, those kinds of non-canonical

00:06:35.860 --> 00:06:39.540
representations. I wonder if there's any use of this kind of stuff for you.

00:06:39.540 --> 00:06:43.380
Yeah. There's something I kind of touch on the pigment section later on, which like the

00:06:43.380 --> 00:06:49.660
attackers typically write scripted attacks and try to obfuscate code using a mix of kind of

00:06:49.660 --> 00:06:53.860
uppercase and putting random dots. I'm just thinking that'd be a nice, potentially a nice

00:06:53.860 --> 00:06:56.200
way of kind of cleaning some of that, that stuff up.

00:06:56.200 --> 00:07:01.020
Yeah, for sure. There was a, there's been some interesting supply chain vulnerability stuff.

00:07:01.020 --> 00:07:06.600
Remember, remember the guy with the color and I think the faker stuff in JavaScript that

00:07:06.600 --> 00:07:14.540
sabotaged his, his libraries. There was another one that maybe well-intentioned. I don't know. It,

00:07:14.540 --> 00:07:19.020
it was some open source library. I don't believe it was Python. I can't remember what it was.

00:07:19.020 --> 00:07:22.640
It could have been, but I'm pretty sure it was in JavaScript because that's where all,

00:07:22.640 --> 00:07:28.440
most of the bad stuff was, it seems. Anyway, they wrote their, they, they taught their dependency

00:07:28.440 --> 00:07:36.120
to erase everybody's hard drive who installed it, who was in Belarus and Russia, which, okay,

00:07:36.120 --> 00:07:40.200
maybe they're trying to contribute, but like it ended up doing a bunch of bad things, even to places

00:07:40.200 --> 00:07:46.460
that were like trying to help say people in the press and journalists do certain things and then like,

00:07:46.460 --> 00:07:51.760
you know, connect with sources and in a race like that database as well. And what they did to make it so

00:07:51.760 --> 00:07:58.180
that nobody would notice in the GitHub commit before it went out to npm was base 64 encode their

00:07:58.180 --> 00:08:03.280
changes. So I basically put a base 64 encoded string and then like decode and then run that.

00:08:03.280 --> 00:08:07.800
And, you know, it's like that kind of stuff. I know this won't solve that problem, but yeah,

00:08:07.800 --> 00:08:10.500
you know, that, that sort of category of like weird representations.

00:08:10.500 --> 00:08:15.920
Yeah. You need mystic pie for something like that. It's one of the things we, yeah, it's a common thing,

00:08:15.920 --> 00:08:19.500
kind of basics before decoding before the obfuscating. But yeah.

00:08:19.500 --> 00:08:24.620
Yeah. Interesting. yeah, I thought of maybe using something like that with,

00:08:24.620 --> 00:08:28.140
because one of the problems we have is like every, every script is kind of slightly different.

00:08:28.140 --> 00:08:34.260
if you could use something like that, essentially kind of apply like sentiment analysis to

00:08:34.260 --> 00:08:38.640
script. I mean, this is a big problem. It's just not something I've particularly solved.

00:08:38.640 --> 00:08:43.080
but that might be a kind of useful, useful thing to just picking out certain things that indicates

00:08:43.080 --> 00:08:46.380
malicious, like format, you know, format drive.

00:08:47.660 --> 00:08:52.080
Exactly. Yeah. You could certainly represent like this one does hard drive stuff. Is this,

00:08:52.080 --> 00:08:55.640
I thought it was parsing colors. Why is it doing things with the hard drive? This is odd,

00:08:55.640 --> 00:09:00.020
you know, like, or with the network, stuff like that. Cool. All right. Well, you know what you

00:09:00.020 --> 00:09:04.140
would really want to check out if you were trying to research these things, probably documentation.

00:09:04.140 --> 00:09:09.700
So I want to tell you all about dev docs, dev docs.io. This is pretty cool. Now, when you get there,

00:09:09.700 --> 00:09:15.800
it's an interesting on my Firefox, it's just got like the mobile view, which is really odd. If you go

00:09:15.800 --> 00:09:20.540
there with a full browser, it's what it believes is the full browser. I guess it's like a slightly

00:09:20.540 --> 00:09:26.220
different view. That's pretty similar, but not the same. So there's, if you open up a whole bunch of

00:09:26.220 --> 00:09:32.640
programming technologies, let's say not just Python or JavaScript or something, but there's also Vue JS.

00:09:33.160 --> 00:09:37.700
There's Werkzeug, for example, like some of the foundation of flash and you can pick the particular

00:09:37.700 --> 00:09:42.340
versions and stuff. So you can go in and like enable these different things. So maybe I care about

00:09:42.340 --> 00:09:47.200
view. I can go over here and enable that one. Let's, we definitely want some Python. Let me go find

00:09:47.200 --> 00:09:52.420
some Python and it gives you all the versions. I'll take that. And let's say I'm also working with

00:09:52.420 --> 00:09:57.160
Postgres. So I'll enable that documentation. And then I might be working with engine X for the front

00:09:57.160 --> 00:10:05.000
and which is somewhere right here. So you can go enable that. And then it will be up near the top

00:10:05.000 --> 00:10:09.200
somewhere here. You can see these are either the default ones or the ones that I checked on. So then

00:10:09.200 --> 00:10:15.420
you can open them up and say, I want to go and see the engine X guide about a debugging log. And then it

00:10:15.420 --> 00:10:22.460
takes you to the documentation for that technology. So it's like a meta documentation repository for all

00:10:22.460 --> 00:10:26.780
of these things all at once, which is pretty cool. Right? So I can go up here and search. I want to

00:10:26.780 --> 00:10:33.100
know about like, let's go about like media tags or something. So you can see the stuff in HTML5. You

00:10:33.100 --> 00:10:38.180
can see the stuff in when you say media, it looks like median. So you can see that in the statistics

00:10:38.180 --> 00:10:44.480
module for Python, some stuff for CSS, or you could come over and say, look, I just want to search for

00:10:44.480 --> 00:10:50.060
CSS. And then you get like using media queries and how to do that kind of stuff. So it's kind of a,

00:10:50.400 --> 00:10:54.400
what you do is you turn on the pieces that are relevant to you, and then you can search across

00:10:54.400 --> 00:11:01.220
those technologies. Cool, right? Wow. Yeah. And, and then if you're on the move, you can come over

00:11:01.220 --> 00:11:09.120
here and turn on offline, offline data, and it'll download all of that as an app so that then you're

00:11:09.120 --> 00:11:13.560
the coffee shopper and you're playing, you now have all the documentation for Python 310, Vue.js,

00:11:13.560 --> 00:11:19.720
Verix.soing, Nginx, et cetera, et cetera, that you can use, which is pretty cool. And this is something

00:11:19.720 --> 00:11:24.660
that drives me crazy about Firefox. They had it and they took it away. And I don't understand why,

00:11:24.660 --> 00:11:29.700
because I'm feeling as firebox is about what the web. So they took away the ability to do progressive

00:11:29.700 --> 00:11:35.000
web apps in Firefox, but all the Chromium browsers support it. So you can actually go and install this

00:11:35.000 --> 00:11:41.460
as a dedicated application on your system. So you, if you have no web, you just click that open. It's

00:11:41.460 --> 00:11:47.540
its own window. You can up, you know, alt tab, command tab between it. Super easy. And then turn on the

00:11:47.540 --> 00:11:52.120
offline mode. And you basically have an app that has offline documentation for all the programming

00:11:52.120 --> 00:11:56.520
technologies that you care about. So this is my new coffee shop buddy.

00:11:56.520 --> 00:12:01.280
Is the search go across the thing you've selected then? So if I search for like replace or something,

00:12:01.280 --> 00:12:03.080
it's the things I've selected.

00:12:03.080 --> 00:12:08.200
Yeah. So if you turn on like JavaScript and Python, it would look for that in both languages.

00:12:08.360 --> 00:12:08.760
Oh, okay.

00:12:08.760 --> 00:12:12.240
Yeah. So basically the ones you turn on, there's a ton of them, right? And you pick,

00:12:12.240 --> 00:12:16.840
you say, these are interesting to me and then search and stuff from what I can tell only applies

00:12:16.840 --> 00:12:21.360
to the technologies you say you care about. Cause like if, if you don't use Java, you really don't

00:12:21.360 --> 00:12:23.900
want to see the documentation for Java search, right? That would be useless.

00:12:23.900 --> 00:12:28.940
Yeah. One of the things I like about this is it also has versions. So, if you're using a,

00:12:28.940 --> 00:12:33.040
like an older version of Postgres, you can just enable that version.

00:12:33.480 --> 00:12:38.120
Right. Sometimes it doesn't matter very much, but other times it matters massively like bootstrap

00:12:38.120 --> 00:12:42.320
three and bootstrap five, they're like fully incompatible basically. Like they're totally

00:12:42.320 --> 00:12:47.240
different keywords and grid systems. And you don't want just the latest. If you've got an old app

00:12:47.240 --> 00:12:51.740
you're working on something like that. Python's more forgiving about that kind of stuff, right?

00:12:51.740 --> 00:12:52.720
It doesn't break as often.

00:12:52.720 --> 00:12:59.620
I was amused that the list though is, it has like three, nine, three, eight for Python

00:12:59.620 --> 00:13:03.440
and it has three 10 at the bottom because one is obviously.

00:13:03.440 --> 00:13:07.980
Cause it's alphabetically sorted. How interesting. Ian, what do you think of this?

00:13:07.980 --> 00:13:13.340
That's very cool. I'm amazed. Is somebody at dev docs kind of manually maintaining all of the links

00:13:13.340 --> 00:13:17.120
to these, like the original source documentation?

00:13:17.120 --> 00:13:21.320
Yeah. Where are they getting it from? Right. I mean, cause there's, they're super disparate.

00:13:21.320 --> 00:13:26.660
It's like matplotlib and markdown and MariaDB. These are all, it's unlikely they're all stored

00:13:26.660 --> 00:13:29.940
in the same basic system. Right. I don't know how they get them actually.

00:13:29.940 --> 00:13:34.580
Yeah. That's very cool. I mean, I know, I normally have solved the same problem by having like 130

00:13:34.580 --> 00:13:38.280
tabs open to different bits of Python docs and pandas and.

00:13:38.280 --> 00:13:42.600
Exactly. Exactly. Yeah. I'm pretty sure they got pandas in here.

00:13:42.600 --> 00:13:47.580
They got numpy as its own thing that we saw matplotlib. There's pandas and there's even,

00:13:47.580 --> 00:13:50.220
you know, versions of pandas across there.

00:13:50.220 --> 00:13:52.600
Single tab solution. Brilliant.

00:13:53.100 --> 00:13:57.480
Yeah. It looks, looks pretty good to me. All right. You want to tell us about what you got

00:13:57.480 --> 00:13:58.240
for your first item?

00:13:58.240 --> 00:14:06.000
Okay. Sure. Yeah. so, as I mentioned earlier, I own a package called mystic pie.

00:14:06.000 --> 00:14:10.960
and first thing to sort out with it is the spelling because I suffer from this on a daily basis,

00:14:10.960 --> 00:14:17.500
mistyping it, even though I've owned it for like three or four years. So it's MSTIC standard for

00:14:17.500 --> 00:14:21.980
Microsoft threat intelligence center. There's no why or anything like that in there. So it's a tool

00:14:21.980 --> 00:14:29.100
set for cybersecurity investigations and hunting in Python, mainly in Jupyter notebooks. So there are a

00:14:29.100 --> 00:14:35.880
couple of questions to ask about that. So firstly, what is cyber security hunting and investigation and

00:14:35.880 --> 00:14:41.980
what it, why are Jupyter notebooks useful? So the first one, cyber sec investigation is really responding

00:14:41.980 --> 00:14:47.140
to alerts or other kinds of threat intelligence and trawling through typically large amounts of

00:14:47.140 --> 00:14:53.280
security logs from cloud services, hosts, account services to determine whether this is a real threat

00:14:53.280 --> 00:14:57.880
or not. And there are two main kinds of... That's one of the huge problems, right? Is you've got all

00:14:57.880 --> 00:15:02.360
these different systems. How are you going to know if someone, if you don't have a tool like this,

00:15:02.360 --> 00:15:05.680
how are you going to know that something, someone's in there rooting around, right?

00:15:06.080 --> 00:15:11.420
Yeah. Yeah. And there are a couple of things that usually trigger this kind of search. So one of them

00:15:11.420 --> 00:15:17.920
is a, an alert may be coming from your seam and that's a, that stands for security, information,

00:15:17.920 --> 00:15:24.320
event management. So the, like a console, like, ArcSight is a traditional one or Microsoft Sentinel

00:15:24.320 --> 00:15:30.580
is a cloud-based one. so you get an alert based on a rule and you need to go in a fairly managed process.

00:15:30.580 --> 00:15:35.520
Somebody needs to go and investigate. Is this a real threat or is this just noise? or there might be something

00:15:35.520 --> 00:15:42.140
like the solar winds, they never a year ago, the log four J, like something in the press or something

00:15:42.140 --> 00:15:49.320
from a threat Intel kind of alert says this kind of threat is around and that's a more ad hoc process kind of hunting.

00:15:49.320 --> 00:15:55.320
Like, do we see this in our organization? so that's kind of what mystic pie is trying to, you know,

00:15:55.320 --> 00:16:00.840
try to address the needs of that. and the second question is why Jupyter notebooks? Why would you do any Jupyter

00:16:00.840 --> 00:16:08.680
notebook rather than in your existing sock tools? I mean, I think there's a lot in common, this kind of

00:16:08.680 --> 00:16:15.480
activity is a lot in common with like big science data, sorry, big, big data science. I mean, something like

00:16:15.480 --> 00:16:21.480
astronomy where you're kind of, you know, hunting for an adversary activity is a little bit like trying to find an exoplanet

00:16:21.480 --> 00:16:25.160
in kind of gigabytes of data or a new quasar or something like that.

00:16:25.160 --> 00:16:31.480
a hundred thousand stars or a hundred thousand lines of log file and you're hunting for some patterns and stuff.

00:16:31.480 --> 00:16:35.000
Right. And you've got a few photons you're trying to determine are these kind of different, you know,

00:16:35.000 --> 00:16:39.560
something like, like, an adversary activity is a little bit like that. It's like millions and millions of events

00:16:39.560 --> 00:16:45.480
and you're trying to find the bad stuff. so traditional sock tools are kind of, you know, can be really excellent.

00:16:45.480 --> 00:16:50.440
And I work with one that I think is, is really good, but, but they all have limitations.

00:16:50.440 --> 00:16:56.760
What's a, a sock tool, a sock tool, a sock security operations center. So, so something like, you

00:16:56.760 --> 00:17:03.400
know, a console that fires alerts and tells you that they have a bunch of analysts, engineers looking

00:17:03.400 --> 00:17:08.040
at this output of this and deciding, and that's the trigger for their investigations. They're like,

00:17:08.040 --> 00:17:10.760
is it like failed log in the SQL server?

00:17:10.760 --> 00:17:15.160
Yeah. Something like that. Or, you know, it could be more sophisticated thing. Like,

00:17:15.160 --> 00:17:20.040
something's exit, you know, tried to access the kind of password data on this, or looks like it's trying

00:17:20.040 --> 00:17:28.920
to access the password data on this host or, or has made a weird kind of configuration change to, mailbox settings.

00:17:28.920 --> 00:17:34.280
So all those kinds of things can kind of trigger alerts and investigations. but you are limited

00:17:34.280 --> 00:17:39.880
in most kind of operation center environments. Notebooks allow you to kind of break out of some

00:17:39.880 --> 00:17:45.720
of the constraints of that. So firstly, you can get data from anywhere. you're not just limited by

00:17:45.720 --> 00:17:50.760
kind of what's in your logs. You could go to virus total or so you can bring data from anywhere.

00:17:50.760 --> 00:17:57.880
you can use customized kind of analysis. so write your own or get, get things from PyPI. Lots

00:17:57.880 --> 00:18:02.760
of people have kind of written this stuff. you control the workflow. So, so you don't have to follow

00:18:02.760 --> 00:18:08.680
what the tool says. You can reorder things, you can backtrack, redo things, and the workflow is repeatable.

00:18:08.680 --> 00:18:14.040
So if you get a similar kind of, you know, issue again, or similar kind of alert, you can

00:18:14.040 --> 00:18:19.960
fish out an old notebook and rerun the same kind of analysis. And you end up with a nice kind of

00:18:19.960 --> 00:18:25.080
shareable document that, it describes your investigation a bit like the results of a

00:18:25.080 --> 00:18:29.160
scientific investigation. It's like, here are all the steps I took and these are the results.

00:18:29.160 --> 00:18:33.880
And this is what they, this is what we determined to be the bad, you know, the bad activity.

00:18:33.880 --> 00:18:40.520
Right. The other thing that seems useful here is Jupyter. Often the notebooks will save the last

00:18:40.520 --> 00:18:45.720
bit of computed information. And then you can go, you know, change a cell, ask the question again,

00:18:45.720 --> 00:18:49.880
change without rerunning the whole thing. And like that's parsing tons of logs or

00:18:49.880 --> 00:18:53.960
pulling them over SSH or whatever that not doing that again is nice.

00:18:53.960 --> 00:18:57.960
Yeah. And it's brilliant. If you don't like doing lots of queries in different browser tabs

00:18:57.960 --> 00:19:01.080
and your browser crashes, they've all gone. What do you do?

00:19:01.080 --> 00:19:06.120
It's all in a Jupyter notebook. I say, it's like second by second, after you do it,

00:19:06.120 --> 00:19:09.320
you can just go back and you can go back to things like you may have done months ago.

00:19:09.320 --> 00:19:11.080
So, yeah, absolutely.

00:19:11.080 --> 00:19:16.920
Yeah. So, so when I started all of this, I kind of thought a lot of this stuff for cyber

00:19:16.920 --> 00:19:21.720
investigations would be available on, and PyPI. I thought great Jupyter notebooks seem like brilliant.

00:19:21.720 --> 00:19:25.640
And there's going to be process tree viewer and there's going to be an event timeline and all this

00:19:25.640 --> 00:19:32.200
kind of stuff. and I found out there wasn't, at least I couldn't find it. so I decided to

00:19:32.200 --> 00:19:37.160
just like stop everything. Need to start writing this, this stuff. So it turns out that things like

00:19:37.160 --> 00:19:42.200
visualizations you need for detecting exoplanets are a bit different from ones you need to detect,

00:19:42.200 --> 00:19:48.440
uh, bad actors. So, so we started building this thing originally me, but there's now, Pete

00:19:48.440 --> 00:19:55.240
Brian and Ashwin Patil also kind of, working on it to my colleagues and a bunch of people in the

00:19:55.240 --> 00:20:01.560
community. It's got four main functional sections. It's like data querying, how you get data in,

00:20:01.560 --> 00:20:07.400
how you do templated queries as enrichment. So for example, if you have something like an IP address,

00:20:07.400 --> 00:20:13.400
you might have a bunch of questions about it as an analyst, like which geographical location is this IP

00:20:13.400 --> 00:20:19.960
address from does it, or any malware reports about it. third areas analysis are things like

00:20:19.960 --> 00:20:25.400
anomaly identification, like the thing you've talking about a spike in, in failed logon events,

00:20:25.400 --> 00:20:29.880
unusual spike in failed logon events, that kind of thing. the final area is visualizations,

00:20:29.880 --> 00:20:34.920
and these are like more specialized. I've got kind of a couple of examples in the show notes.

00:20:34.920 --> 00:20:40.840
this is like anomaly identification pattern. This is one of, one of the custom, we use Bokeh,

00:20:40.840 --> 00:20:45.560
uh, which I really, this is really nice kind of visualization package, to allow you to kind

00:20:45.560 --> 00:20:51.160
of view data in a way that analyst kind of expects you to s to see it a bit. So they're more of this

00:20:51.160 --> 00:20:56.120
kind of visualization than more traditional kind of graphs. I would much rather look at this than

00:20:56.120 --> 00:21:00.520
log files or event logs or, or whatever, you know? Yeah. That's the whole thing about, you know, you,

00:21:00.520 --> 00:21:04.920
you, you need, you may have thousands of events and you need to get down to the few that are the

00:21:04.920 --> 00:21:10.840
interesting, the interesting thing. so one of the areas that we've, we try to focus on

00:21:10.840 --> 00:21:15.960
currently, cause we wrote all this stuff and you have like hundreds of functions that you could use,

00:21:15.960 --> 00:21:21.400
but it's kind of difficult to discover them. And they all, cause they evolved a little bit organically.

00:21:21.400 --> 00:21:26.360
Like how do you, they were working a little bit of a different way, different set of parameters.

00:21:26.360 --> 00:21:31.800
So the work we're currently doing is trying to make this all a bit more accessible. So all of the

00:21:31.800 --> 00:21:36.760
functions that relate to say an IP address, all the questions you want to ask about it are kind

00:21:36.760 --> 00:21:41.640
of dynamically attached to a class called IP address. So they're all like things like,

00:21:41.640 --> 00:21:44.600
Oh, interesting. Do, do, do. So you don't have to work just with a raw

00:21:44.600 --> 00:21:49.800
string or just some raw IP representation, but you can ask it questions like its location.

00:21:49.800 --> 00:21:55.160
Well, it's not quite that intelligent. It's even a bit less intelligent than Alexa, but, but it's,

00:21:55.160 --> 00:22:00.440
but it's more like, you know, there might be things like geolocation of an IP address,

00:22:01.080 --> 00:22:07.400
threat intel lookups, different queries that might be, have IP addresses like a, a parameter.

00:22:07.400 --> 00:22:12.760
and previously you'd have to go and find all of these things and import them separately and run

00:22:12.760 --> 00:22:17.800
them. but now they're all kind of dynamically attached as methods to the fact that use IP address

00:22:17.800 --> 00:22:22.840
as a parameter means that you just have one object to import, and then you can do all of these different

00:22:22.840 --> 00:22:27.960
operations, on this single item. there's, there's some things that don't work with that.

00:22:27.960 --> 00:22:33.640
Some things like the visualizations, for example, they're not IP address or host or account specific.

00:22:33.640 --> 00:22:39.960
They work on big blocks of data. So the other area we're working on is try to anything. It takes a

00:22:39.960 --> 00:22:46.680
bunch of data as an input. We're writing those as pandas excesses. so they appear as methods to a

00:22:46.680 --> 00:22:53.000
data frame. So you do kind of data frame dot MP plot dot timeline, right? And it would produce your

00:22:53.000 --> 00:22:57.640
timeline as long as it's the right kind of data or, so yeah, that's one of the challenges of

00:22:57.640 --> 00:23:02.200
writing this kind of thing organically is you end up with a lot of stuff, but nobody knows it's there

00:23:02.200 --> 00:23:07.640
and everybody knows how to import it. So try to make it as accessible so that it just becomes a very

00:23:07.640 --> 00:23:12.680
intuitive thing. Oh, I have an IP address. What functions can I do? I can do this, you know,

00:23:12.680 --> 00:23:14.680
it's all like tab completable, that kind of thing.

00:23:14.680 --> 00:23:21.400
Yeah, I think it's really cool. You've taken this Python data stack view of cyber security and threat

00:23:21.400 --> 00:23:22.360
detection. Yeah.

00:23:22.360 --> 00:23:23.320
Yeah. Brian, what do you think?

00:23:23.320 --> 00:23:29.960
well, it's definitely a complicated area. and it trying to, one of the things I like about this

00:23:29.960 --> 00:23:36.120
story is just talking about the complexities in API design, and discoverability that's a,

00:23:36.120 --> 00:23:39.320
that applies to like lots of different fields, but yeah.

00:23:39.320 --> 00:23:42.360
Yeah. It's one of those things you should have thought about at the beginning, but,

00:23:42.360 --> 00:23:47.960
even at the end, you can tidying things up. yeah. So,

00:23:47.960 --> 00:23:49.320
Famous last word.

00:23:49.320 --> 00:23:55.400
So yeah, we're definitely open for like other people collaborating, contributing stuff,

00:23:55.400 --> 00:23:56.760
cause there's a lot of ground to cover.

00:23:56.760 --> 00:24:04.360
yeah, for sure. It's on GitHub. I saw one final question before we move on. Is it just for Azure

00:24:04.360 --> 00:24:08.440
or is, is this a thing that more broadly works across different systems?

00:24:08.440 --> 00:24:11.480
No, I think I should have mentioned that a little bit earlier on it. We originally built

00:24:11.480 --> 00:24:16.120
it for Microsoft Sentinel notebooks, but it supports like Splunk, Defender,

00:24:16.120 --> 00:24:21.880
working on an elastic provider. So really anything you can get into a pandas data frame,

00:24:21.880 --> 00:24:26.840
you can use most of the functionality. So even if we don't, we don't have a provider ourselves,

00:24:26.840 --> 00:24:32.920
if you've got something like PySpark and you can get a data frame, then all of our functions take

00:24:32.920 --> 00:24:37.560
data frame. You know, we use pandas as our universal data interchange format.

00:24:37.560 --> 00:24:44.440
Yeah, indeed. Indeed. Kim Van Wick out in the audience likes it. It's way like a much nicer way

00:24:44.440 --> 00:24:49.240
to glean info and logs and complex grip. I'm, I'm right there with you. All right. Now, before we

00:24:49.240 --> 00:24:55.400
move on, Brian, let me tell you about our sponsor for this episode. This episode of Python Bytes is

00:24:55.400 --> 00:25:01.240
brought to you by Fusion Auth. Fusion Auth is an authentication and authorization platform built by

00:25:01.240 --> 00:25:07.240
devs for devs. It solves the problem of building essential user security without adding risk or

00:25:07.240 --> 00:25:12.680
distracting from the primary application. Fusion Auth has all the features you need with great support and

00:25:12.680 --> 00:25:18.200
a price that won't break the bank. And you can either self-host it or get the fully managed solution

00:25:18.200 --> 00:25:23.800
hosted in any AWS region. Do you have a side project that needs custom login and registration,

00:25:23.800 --> 00:25:29.160
multi-factor authentication, social logins, or user management? Download Fusion Auth community

00:25:29.160 --> 00:25:35.240
edition for free. The best part is you get unlimited users and there's no credit card or subscription

00:25:35.240 --> 00:25:41.800
required. Learn more and get started at pythonbytes.fm/fusionauth. The links in your show notes.

00:25:41.800 --> 00:25:45.800
Thank you to Fusion Auth for supporting the show. All right. What do you got for your next one,

00:25:45.800 --> 00:25:49.160
Brian? Number, numbers, something every computer scientist should know?

00:25:49.160 --> 00:25:56.360
Yes. Floating point. Arithmetic is complicated. And so when I started, started working in

00:25:56.360 --> 00:26:01.480
professionally, one of the things I was recommended reading was, an article called what every

00:26:01.480 --> 00:26:06.600
computer scientist should know about floating point arithmetic. And don't worry, it's only like a

00:26:06.600 --> 00:26:13.320
really long paper with lots of math. so I am not telling you to read this, although it is an

00:26:13.320 --> 00:26:19.400
interesting read. What I would like you to read is this article by David Amos called the right way to

00:26:19.400 --> 00:26:24.840
compare floats in Python, because there's a few things that we need to know about floats when we're

00:26:24.840 --> 00:26:30.360
using them and floating points is, and he covers all of this in the article without going through

00:26:30.360 --> 00:26:37.240
tons of scary math is the floating point numbers have to be represented in a way that can the computer

00:26:37.240 --> 00:26:43.960
can store them and use them and manipulate them, even though some numbers are huge and won't fit

00:26:43.960 --> 00:26:49.400
normally. So we have to do things like accept that there's error and rounding. So there's a little bit

00:26:49.400 --> 00:26:54.600
of a discussion there that he talks about. One of the things that surprises people sometimes when they

00:26:54.600 --> 00:27:00.040
first come come into Python, but it's not just Python, it's most, most languages is somewhere.

00:27:00.040 --> 00:27:06.600
There's going to be something obvious that doesn't work like in, in Andy or David's example, 0.1

00:27:06.600 --> 00:27:14.760
plus 0.2 equals or comparison equals, 0.3. And that will show up as false because they don't.

00:27:14.760 --> 00:27:21.800
And this is weird. They obviously are crazy that that doesn't work, but, but it's not just equals.

00:27:21.800 --> 00:27:27.160
You can also do comparisons like, you know, less than or greater than. So it's not only is that,

00:27:27.160 --> 00:27:34.200
are they not equal? They're not like 0.1 plus 0.2 is not even less than or equal to 0.3. It's weird.

00:27:34.200 --> 00:27:42.760
so, so what do you do? You don't, the gist of it is don't compare things with a normal

00:27:42.760 --> 00:27:49.080
math comparisons if there's floating points involved. So what you want to do instead is, and there's,

00:27:49.080 --> 00:27:54.280
here's a little tiny bit of math, way less than the, than the example. the thesis,

00:27:54.280 --> 00:27:59.240
the dissertation. Yeah. so there's a whole bunch of stuff built into Python that you can,

00:27:59.240 --> 00:28:05.480
um, to, to, to work with comparisons. And one of the most common ones I'm trying to get there

00:28:05.480 --> 00:28:11.320
is, math is close. So there's a math library that's, it's that with an is close function

00:28:11.320 --> 00:28:18.920
that it's used to just say, Hey, I've got two values. Are these close, close enough? and,

00:28:18.920 --> 00:28:25.000
we, when, if you're using, if you have to compare floats, something like this is, is great. And be

00:28:25.000 --> 00:28:29.960
underneath the scene behind the scenes, what it does is it's, it's taking the two values and

00:28:29.960 --> 00:28:36.840
subtracting them and figuring out if the Delta is, or the absolute value of the Delta is below some

00:28:36.840 --> 00:28:41.560
tolerance, some reasonable tolerance, like close enough. And what that tolerance is,

00:28:41.560 --> 00:28:47.880
is either a relative or absolute tolerance. And, you, most of the time you can kind of get away

00:28:47.880 --> 00:28:52.200
with not caring about that, but if you do care about it, you can control that you can pass in

00:28:52.200 --> 00:28:57.560
what tolerance you expect things to be closer to. I use stuff like this all the time with,

00:28:57.560 --> 00:29:02.760
with test equipment, because I definitely want to know, control over the tolerance levels.

00:29:02.760 --> 00:29:08.200
So, yeah, for sure. So there's math is close, but then there's also, I'm not going to

00:29:08.200 --> 00:29:13.240
scroll all the way down here, but there's, there's, he also covers numpy. So numpy has got a

00:29:13.240 --> 00:29:19.240
couple of these that are really great. One of them is, is, is close also, but it works on arrays and

00:29:19.240 --> 00:29:25.560
it'll give you an array of, true and false values, but you can also use all close,

00:29:25.560 --> 00:29:30.840
which just says you've got two arrays. And if all of the pairs are close enough,

00:29:30.840 --> 00:29:37.000
it'll match those up. also covered, which, we use during testing a lot is py test prox,

00:29:37.000 --> 00:29:43.640
which is a little bit of a different beast, but, but David covers that. So, basically this

00:29:43.640 --> 00:29:49.880
is a semi regular reminder to anybody using floating point math in Python that you should be careful

00:29:49.880 --> 00:29:55.400
with it or any other language. So. Yeah. It's not a Python thing. It's just a fit representing

00:29:55.400 --> 00:29:59.960
things that don't fit. Now there's some things sometimes where you have to be very exact.

00:29:59.960 --> 00:30:05.560
You need to be very precise. And in those cases, Python does have the decimal and fraction types.

00:30:05.560 --> 00:30:10.440
and David covers these in the article, which are cool. They're cool things to know about,

00:30:10.440 --> 00:30:17.160
like definitely around, people using money or, or other, very high precision. But if you're

00:30:17.160 --> 00:30:23.720
also, so there's, those are covered. They do get some sort of a hit for those. But if you really care about,

00:30:23.720 --> 00:30:29.560
like the precision and want to want to do things exactly right, then you probably should read that

00:30:29.560 --> 00:30:34.120
larger article because there's things that you have to do like, certain operations before

00:30:34.120 --> 00:30:39.800
other operations to try to keep the area error from accumulating too high. So there's, it gets messy.

00:30:39.800 --> 00:30:40.280
Interesting.

00:30:40.280 --> 00:30:45.720
I think I'm fundamentally disturbed by the idea that zero isn't zero. So my approach to floating

00:30:45.720 --> 00:30:53.560
point numbers is normally convert them to ints. Yeah. I was thinking that, yeah, sometimes that is

00:30:53.560 --> 00:30:59.320
the way to do it. Right. I was thinking this kind of stuff maybe applies a lot to the project that

00:30:59.320 --> 00:31:05.400
you're working on. If you're trying to come up with ratios that represent, you know, how risky something

00:31:05.400 --> 00:31:10.760
is and things like that. Yeah. Yeah. Yeah. I mean, certainly a lot of, yeah, I was being a bit

00:31:10.760 --> 00:31:17.080
flippant before. It's just as fun. It's like, I'm a very platonic at heart. I think so. Like zeroed

00:31:17.080 --> 00:31:22.040
one should be zero one, not nearly one of nearly zero. There should be a perfect square in a perfect

00:31:22.040 --> 00:31:27.960
circle. Like how can they not exist in our language? Is it really zero or negative zero?

00:31:27.960 --> 00:31:37.880
Henry on the audience. Henry also points out that PI test approximate also works on numpy arrays as

00:31:37.880 --> 00:31:38.680
well. Nice.

00:31:38.680 --> 00:31:39.080
Which is pretty cool.

00:31:39.080 --> 00:31:39.640
Cool.

00:31:39.640 --> 00:31:39.640
Cool.

00:31:39.640 --> 00:31:45.080
You can put that all together. All right. Let me tell you all about Piper. I think that's,

00:31:45.080 --> 00:31:49.800
that might be the representation, the way you pronounce it. Everything needs its own description,

00:31:49.800 --> 00:31:57.320
its own like little phonetic bit. So this, this is a, a simple way to create scripts that run and do

00:31:57.320 --> 00:32:02.840
stuff on your computer using Python. And what's cool about it is it has a real simple way to define

00:32:02.840 --> 00:32:07.640
the steps. Some of those steps can be optional, but then you can also piece together things like

00:32:07.640 --> 00:32:13.240
other programming. So you can combine commands, different scripts in different languages and

00:32:13.240 --> 00:32:20.120
applications all into one sequence of events that happens on your computer. So it's basically a task

00:32:20.120 --> 00:32:25.560
runner where you define stuff in YAML. And probably the best way to see is to go check out the docs. And

00:32:25.560 --> 00:32:30.120
there's a whole bunch of docs. The docs are really nice here actually. So for example,

00:32:30.120 --> 00:32:35.720
if you go to getting started and come down here and run your first pipeline, I really like the way

00:32:35.720 --> 00:32:41.160
the docs here look, how they look, but the way you define it, here's like a one, one step one is you

00:32:41.160 --> 00:32:47.080
just say the steps and it's all YAML and give a step a name so you can refer to it. And then you have inputs

00:32:47.080 --> 00:32:51.640
and outputs and outputs and you do the little curly string interpolation types of things. Or you can

00:32:51.640 --> 00:32:57.720
have more complex ones like with different steps and you can even have little comments. There's a way to

00:32:57.720 --> 00:33:03.720
put a comment in your YAML file as well. So there's also conditional. Let's see if I can find a good

00:33:03.720 --> 00:33:09.640
conditional one down here. Here's on it goes and works with like, this one is just an echo

00:33:09.640 --> 00:33:14.120
statement and the ping command, but you know, whatever, whatever you want to do, you can basically

00:33:14.120 --> 00:33:21.080
pass command line arguments to the YAML file or to the workflow, the pipeline, and it'll take those and

00:33:21.080 --> 00:33:27.480
feed them into the steps. So for example, when you call it, you can say like count equals one and IP

00:33:27.480 --> 00:33:32.680
equals that. And those will come the little string interpolated pieces that go in there. So you can

00:33:32.680 --> 00:33:38.440
just combine whatever, basically whatever commands are available to the shell, right? Be that Python or

00:33:38.440 --> 00:33:42.760
POSIX or windows or PowerShell or whatever you're looking to do. Pretty cool, huh?

00:33:42.760 --> 00:33:49.080
Hmm. That's pretty neat. I might need this for my, my job of, automating my show notes.

00:33:49.080 --> 00:33:50.520
I might use some of this.

00:33:50.520 --> 00:33:54.360
Oh yeah, there you go. If you can find this, go do that. And so on, like, here's one

00:33:55.160 --> 00:33:59.720
that sort of uses the truthiness. So it says there's a bunch of different steps and the,

00:33:59.720 --> 00:34:06.200
you can use the run flag. So here it says run if there's a value for a on this one. And this one

00:34:06.200 --> 00:34:10.440
says run if there's a value for B. And then there's an example where it says, okay, we run it by itself.

00:34:10.440 --> 00:34:15.480
Those don't run. But if you pass a, then it runs that a step. If you pass B, it does the B step,

00:34:15.480 --> 00:34:20.360
or it can do both if you pass them both. And I like the simplicity of it. Like a lot of these tools,

00:34:20.360 --> 00:34:22.840
like this feel like they're pretty complicated.

00:34:22.840 --> 00:34:26.840
You know, you're sort of like your example with the Genshin, Brian, where you're like,

00:34:26.840 --> 00:34:31.800
is this thing too heavy weight for what I'm trying to ask it to do? You know? And this seems like a

00:34:31.800 --> 00:34:34.840
real simple thing. And I don't have to learn about make or any of those kinds of things.

00:34:34.840 --> 00:34:40.840
Yeah. GitHub actions or, yeah. Yeah. Yeah. It's got a bit of a GitHub actions feel to it.

00:34:40.840 --> 00:34:45.240
That's, but it seems like a nicer kind of declarative. That's really cool.

00:34:45.240 --> 00:34:49.720
Indeed. Yeah. If you were not, not into programming or you didn't want your steps to be programming,

00:34:49.720 --> 00:34:55.320
but of course what happens at each step, you could call a Python app or script. That's going to do

00:34:55.320 --> 00:34:59.000
something complicated, right? If it needs to, can you, can you, the orchestration of that,

00:34:59.000 --> 00:35:03.160
you don't have to make complicated. Is it just a command line too? Or can you invoke it from Python?

00:35:03.160 --> 00:35:09.480
Might be a bit interesting. I'm sure there's, there's a way to import it and make it do, do a thing. You

00:35:09.480 --> 00:35:14.600
know, it's probably just a Python package with an entry point in this package. So I would think so.

00:35:14.600 --> 00:35:18.520
Yeah. Cause it would be nice to be able to do that rather than just using sub process to invoke a lot

00:35:18.520 --> 00:35:23.880
of things. Like if you're in. Oh, interesting. I hadn't really thought about it as a replacement for

00:35:23.880 --> 00:35:28.680
sub process, but yeah, because a lot of times when you're trying to orchestrate stuff, like it talks

00:35:28.680 --> 00:35:34.360
about here being part of the shell or being another app or another language, you would just use sub process

00:35:34.360 --> 00:35:40.200
on it. Right. Yeah. Cool. Well, there it is. Piper, Piper.io and people can check that out. It looks,

00:35:40.200 --> 00:35:44.520
looks pretty interesting. Nice. All right. Ian, you want to take us out with your final item here?

00:35:44.520 --> 00:35:49.640
Ah, pigments. Okay. So this is a package. I mean, if you were a developer, there's a very good chance

00:35:49.640 --> 00:35:54.440
that you have been using this for years without, like me, without knowing about it. You might have

00:35:54.440 --> 00:35:58.840
seen it being installed as like a dependency. It's like, what is that thing? That was my thought,

00:35:58.840 --> 00:36:03.240
Ian. I'm like, I know I see this all the time in my dependencies and I just never really bothered to

00:36:03.240 --> 00:36:09.640
look into what it does. Yeah. So I hadn't until recently. So if you use, if you use Jupyter Notebook

00:36:09.640 --> 00:36:16.520
markdown, you know, you can look like three backticks and, and then a block of code. And you can actually

00:36:16.520 --> 00:36:23.240
put like Python or bash or something as a, and it will intelligently highlight it. So the thing that's

00:36:23.240 --> 00:36:28.280
doing that intelligent highlighting is pigments, GitHub markdown, same kind of thing. Although I'm not

00:36:28.280 --> 00:36:34.520
sure whether GitHub uses pigments. And if you do developer docs, like reader docs and Sphinx,

00:36:34.520 --> 00:36:41.000
that also uses pigments to kind of color code your, your code samples. And I know there's a lot of,

00:36:41.000 --> 00:36:45.560
uh, you know, writing kind of blog posts and stuff like that. You, there are some,

00:36:45.560 --> 00:36:50.360
quite a few services out there where you can take a chunk of code and it will, intelligently

00:36:50.360 --> 00:36:56.760
highlight it and give you a, a JPEG or a PNG back. And that's kind of nice, but then you can't copy

00:36:56.760 --> 00:37:00.600
and paste the code from those samples. So I don't like that really. I think if you're going to put

00:37:00.600 --> 00:37:05.480
code in a article, you, you're probably intended for people to be able to copy and paste it.

00:37:05.480 --> 00:37:08.040
Yeah. That's the most likely thing you are to copy and paste.

00:37:08.040 --> 00:37:08.360
Yeah.

00:37:08.360 --> 00:37:10.440
Yeah. Right. Cause you want that code over here.

00:37:10.440 --> 00:37:13.960
Yeah. You don't want an image of your, I mean, cause you could use OCR to like reinterpret it,

00:37:13.960 --> 00:37:19.560
but it's all, yeah. And then maybe, maybe Brian's gen sim to like, tidy it up.

00:37:19.560 --> 00:37:27.000
but, so with pigments, you can use it as a standalone package and it can do this kind of

00:37:27.000 --> 00:37:33.320
rendering, and it can render to like HTML with like CSS style sheets for all of the coding. It also

00:37:33.320 --> 00:37:40.200
rendered to like NC terminal, latex, a few other, other kinds of things. So if you're using,

00:37:40.200 --> 00:37:45.480
um, you know, if you want to get a nicely formatted piece of code in, in a document or you're doing

00:37:45.480 --> 00:37:50.120
developer docs, it's certainly kind of useful. I mean, I came across it. or should I just say

00:37:50.120 --> 00:37:55.880
one thing that also supports, maybe I can just switch supports lots and lots of languages. So it's,

00:37:55.880 --> 00:38:02.200
um, very simple to use. It has a highlight function. and then you import Alexa, which is like the

00:38:02.200 --> 00:38:08.040
thing that understands the tokens in a language and the, a formatter for the output type you want.

00:38:08.040 --> 00:38:12.520
And I think there's hundreds of these things. So, and, and, and there are a lot of languages in there.

00:38:12.520 --> 00:38:13.080
No kidding.

00:38:13.080 --> 00:38:17.480
I'm more than half of these I've never heard of. And it also supports as well as things like,

00:38:17.480 --> 00:38:22.760
you know, you'd expect Python, it supports Python tracebacks. So it has separate Lexer for color

00:38:22.760 --> 00:38:28.760
coding tracebacks. all the usual languages you'd expect, but also some things like data formats,

00:38:28.760 --> 00:38:36.760
like, Toml, Jason, XML. okay. Interesting. Like a lot of the files that we might run across.

00:38:36.760 --> 00:38:37.160
Yeah.

00:38:37.160 --> 00:38:37.560
Yeah.

00:38:37.560 --> 00:38:44.040
Yeah. and so it's very, very easy to use. And the reason I came across it is because I,

00:38:44.040 --> 00:38:51.240
it recently, so a lot of attacker code tends to be a deliberately obfuscated. So it's kind of base

00:38:51.240 --> 00:38:57.240
64 encoded, but then even once you decode it, it's kind of munged in a way to make it as unreadable as

00:38:57.240 --> 00:39:03.240
possible. So one of the things that we try to do is, is pull that code back, like decode it, trying to re

00:39:03.240 --> 00:39:09.640
like clean it, deobfuscate it. but if you have, if you can present it in a, as close to the way a

00:39:09.640 --> 00:39:14.040
developer would write it as possible, it makes it much quicker for an analyst to determine what,

00:39:14.040 --> 00:39:21.160
what is this doing? so we've used it now in, in mystic pie to kind of, color display things like,

00:39:21.160 --> 00:39:26.760
well, it's just power shell script or, bash or something like that. So that's how I came across it.

00:39:26.760 --> 00:39:32.360
Actually, rather than just seeing it go past as part of a pip install, actually have to invoke it

00:39:32.360 --> 00:39:38.280
directly. So, so I kind of big shout out to the developers and maintainers of pigments.

00:39:38.280 --> 00:39:43.080
It's one of those package that probably millions of people benefit from, but like very few people

00:39:43.080 --> 00:39:48.760
kind of know about it or, you know, you can, and it's just super easy to use. They seem to be adding

00:39:48.760 --> 00:39:54.760
kind of flexors all the time. So, great. Yeah, this is amazing. I didn't realize that it did all

00:39:54.760 --> 00:40:00.120
of this. This is a way more advanced than I thought. Brian, did you know? No, I just thought it was

00:40:00.120 --> 00:40:04.120
something that magically syntax did syntax highlighting. So I didn't have to care about it.

00:40:04.120 --> 00:40:13.400
Yeah, exactly. I got a little example in the, in the show notes as well. I posted it has a dark theme.

00:40:13.400 --> 00:40:18.600
Yeah. Yeah. yeah. And you, you probably want to include this no background equals true

00:40:18.600 --> 00:40:23.800
if using a Jupyte Notebooks. Cause if, if you select a theme, it just flips the whole notebooks kind of

00:40:23.800 --> 00:40:29.960
CSS theme. So that tells it just not to mess with what, what's in the background. Okay. yeah,

00:40:29.960 --> 00:40:34.600
that looks great. Yeah. Thanks. Thanks for pointing out how useful that can be. That's, that's cool.

00:40:34.600 --> 00:40:39.080
Like I said, I've seen it go by all the time. I just never really paid that much attention to it.

00:40:39.080 --> 00:40:42.920
It's probably a pretty minority use, but like if you need it, it's great.

00:40:42.920 --> 00:40:46.840
Yeah. It's incredibly powerful. Fantastic. Well, that's all of our main items. Brian,

00:40:46.840 --> 00:40:51.880
you got any extras? just one extra, actually. One of the things when I was doing that, the

00:40:51.880 --> 00:40:57.240
first topic with GenSim, the, one of the dependent, it doesn't have very many dependencies,

00:40:57.240 --> 00:41:03.560
but one of the dependencies is this, this library called smart open. And I'm like, what? I,

00:41:03.560 --> 00:41:09.480
I open things and I want to be smart about it. So I wanted to check this out and it's pretty neat.

00:41:09.480 --> 00:41:15.400
I don't know if we've covered this before, but it's a, it basically mimics the interface of open

00:41:15.400 --> 00:41:22.200
normal Python open, but you can pass it really anything in. And it does, like,

00:41:22.200 --> 00:41:29.160
transparent on the fly reading of things, efficient streaming of large files from like S3 or Azure

00:41:29.160 --> 00:41:31.400
or, or over the web.

00:41:31.400 --> 00:41:35.880
Even straight just HTTP. Yeah. If you just have a link to a large file on a web server.

00:41:35.880 --> 00:41:41.880
Yeah. And, and then just the code for it is just like super nice. You know, you, you import open

00:41:41.880 --> 00:41:49.880
from smart open and you got like four line in open this thing and, just, you can work from each

00:41:49.880 --> 00:41:51.400
line there. It's pretty cool.

00:41:51.400 --> 00:41:56.840
I love it. That's a, that's a great one. Very nice. Ian, you got any extras you want to

00:41:56.840 --> 00:41:59.960
shout out while we're here? I don't, I'm afraid.

00:41:59.960 --> 00:42:07.720
I have, I have, I have two real quick ones, to just quickly talk about. Last time,

00:42:07.720 --> 00:42:14.360
Emily Morehouse spoke about using auto squash, which was really cool. So Adam,

00:42:14.360 --> 00:42:20.920
let me get the attribution correct here. Adam Park Parkin sent in a follow-up to say,

00:42:20.920 --> 00:42:25.000
hey, you should check out this article over here called fixing commits with

00:42:25.000 --> 00:42:29.960
git commit --fix up and git rebase --auto squash.

00:42:29.960 --> 00:42:34.760
Woo. The long and the short of it is talks about doing a lot of things that Emily said was pretty

00:42:34.760 --> 00:42:42.440
cool, but in the end setting up your.git config to auto squash equals true, and then adding an alias.

00:42:42.440 --> 00:42:47.640
So you can just type git space fix up. And when you type that, it actually does get log and shows

00:42:47.640 --> 00:42:54.280
the last 50 items and then allows you to go back and work with those. And basically it's just a real

00:42:54.280 --> 00:43:00.120
quick way to get back into the scenario where you mark different elements for fix up. So people can

00:43:00.120 --> 00:43:05.480
check that out if they were following Emily's advice, but they want it to be like one line. They

00:43:05.480 --> 00:43:11.720
don't have to remember. There you go. That's cool. And then Python 310.3 is out as of about a week

00:43:11.720 --> 00:43:17.720
ago, I suppose. So there are many changes amongst here. You know, I would love, there's like so many

00:43:17.720 --> 00:43:22.120
great changes here. I don't know how many do you think that is probably a hundred, maybe a little

00:43:22.120 --> 00:43:28.120
bit less. It would be great if there was like a, these are critically important at the front. Like

00:43:28.120 --> 00:43:32.760
there's a security problem that was fixed, or there's a thing we've taken out is no longer here.

00:43:33.720 --> 00:43:37.720
They're kind of all the same priority. But nonetheless, there's a bunch of changes that

00:43:37.720 --> 00:43:41.720
people can check out and upgrade to the newer version of Python 310.

00:43:41.720 --> 00:43:47.400
different people care about different stuff though. I know. I don't want to impose my importance on

00:43:47.400 --> 00:43:52.600
other people's importance. Yeah. So it's funny when I first came across, first came across Python,

00:43:52.600 --> 00:43:57.240
you were kind of like, why is it so slow between the major versions coming out? But then suddenly

00:43:57.240 --> 00:44:00.600
it's like a Python developer. It's like, why are the versions coming out so quickly?

00:44:00.600 --> 00:44:08.600
Yeah. It's definitely true. There's a ton of change. This is just, you know, some minor version

00:44:08.600 --> 00:44:11.480
change that has these, all these changes in here, which is pretty cool.

00:44:11.480 --> 00:44:16.040
Well, we also used to be on an 18 month cycle and now we're on a yearly cycle. So just yeah.

00:44:16.040 --> 00:44:23.080
Yeah. Lucas Schlinger's fault that we are 50% faster now. Thanks Lucas. All right. How about a joke to

00:44:23.080 --> 00:44:24.760
close out the show? That'd be great.

00:44:24.760 --> 00:44:32.280
Yeah. So here's a good tweet and it's this sort of perplexed, I think in a good way,

00:44:32.280 --> 00:44:38.440
character wearing all these, are these prizes? I don't know. Anyway, Python developers, when someone

00:44:38.440 --> 00:44:44.120
asks what their secret is, and this person just says, I just keep writing pseudocode and it just keeps

00:44:44.120 --> 00:44:50.200
working. It's a little bit like that joke where they have some code, pseudocode in a text file.

00:44:50.200 --> 00:44:55.720
They're like, just rename it to .py and try to run and see what happens. Anyway, that's the joke.

00:44:55.720 --> 00:44:56.040
Nice.

00:44:56.040 --> 00:44:59.480
Thank you, Brian, as always. And Ian, thanks for being part of the show.

00:44:59.480 --> 00:45:00.520
Thank you. Great to have you here.

00:45:00.520 --> 00:45:02.680
Thank you very much both. It's been a real pleasure.

00:45:02.680 --> 00:45:04.440
Yeah, it sure has. See y'all.