aws waf sql注入
Have you ever drawn some wonderful tabular data on a piece of paper and thought, “Wouldn’t it be nice if I could run an SQL query on this”?
您是否曾经在纸上绘制过一些很棒的表格数据,并想过:“如果我可以对此进行SQL查询,那会不会很好?”
Have you ever wondered if the animals in George Orwell’s Animal Farm could have benefited from AWS to categorise which animals were good or bad using only serverless components?
您是否曾经想过,乔治·奥威尔(George Orwell)的动物农场中的动物是否可以从AWS中受益,从而仅使用无服务器组件对哪些动物是好动物还是坏动物进行了分类?
If you answered yes to at least one of these questions, then have I got a story for you.
如果您对至少其中一个问题的回答是“是”,那么请问我有个故事吗?
TLDR; Yes it can be done! Draw table -> Scan it -> Use Amazon Textract to convert to CSV -> Upload CSV to S3 -> Run a Glue crawler -> Query table using Athena -> Success.
TLDR; 是的,可以做到! 绘制表格->扫描->使用Amazon Textract转换为CSV->将CSV上传到S3->运行胶水搜寻器->使用雅典娜查询表->成功。
I drew this table as neat as I could — probably should have used a ruler but ¯\_(ツ)_/¯.
我尽可能整齐地画了这张桌子-可能应该使用尺子,但是\\(ツ)_ /¯。
So how can I convert this into a machine readable format? Enter Amazon Textract.
那么如何将其转换为机器可读格式? 输入Amazon Textract。
According to the documentation,
根据文档,
“Amazon Textract is a service that automatically detects and extracts text and data from scanned documents. It goes beyond simple optical character recognition (OCR) to also identify the contents of fields in forms and information stored in tables”
“ Amazon Textract是一项服务,可自动检测并从扫描的文档中提取文本和数据。 它不仅可以识别简单的光学字符识别(OCR),还可以识别表格中的字段内容和表格中存储的信息”
This sounds perfect, but can it recognize handwriting? Let’s find out…
听起来很完美,但是可以识别手写吗? 让我们找出……
Turns out that worked 原来那行得通That actually worked — but TBH it took a bunch of attempts before I got it right. The first iteration of my table it thought my writing of the word GOOD was “GOOL or GOOI”, and it generally struggled with the way I usually write the number 2 and thought it were the letter d. Case in point…
这实际上是有效的-但是TBH在我做对之前进行了很多尝试。 在表的第一次迭代中,它认为我写的“ GOOD”是“ GOOL或GOOI”,并且通常与我通常写数字2的方式并认为它是字母d格格不入。 例子……
2 d or not 2 d — that is the question 2 d还是不2 d-这就是问题That said, the character recognition of my cursive handwriting is actually pretty good — way better than I expected.
就是说,我的草书手写体的字符识别实际上非常好-比我预期的要好得多。
Once I got my handwriting in order, Textract recognized everything, and then I could export my beautiful table into a CSV.
一旦我的笔迹整理好了,Textract就可以识别所有内容,然后可以将漂亮的表格导出到CSV中。
Yes it’s Excel 2007 是的,这是Excel 2007Make an S3 bucket, upload the CSV to it.
制作一个S3存储桶,将CSV上传到其中。
Yes it is a silly-experiment 是的,这是一个愚蠢的实验Now we have our data in an S3 bucket, before we can run some queries on it we need to analyse the data and create a schema. We could create this schema manually rather than using a Glue crawler, but that would defeat the purpose of these exercise, so here we go.
现在,我们将数据存储在S3存储桶中,然后才能对其进行一些查询,我们需要分析数据并创建模式。 我们可以手动创建此模式,而不是使用Glue搜寻器,但这会破坏这些练习的目的,所以我们继续。
Below is the configuration of the Glue crawler I have setup. Basically what this is going to do is look through all the CSV files in my S3 bucket (I only have one), work out the schema of the data, and map it to a database called animal-morality.
以下是我已设置的Glue搜寻器的配置。 基本上,要做的就是浏览我的S3存储桶(我只有一个)中的所有CSV文件,计算出数据的模式,然后将其映射到名为animal-morality的数据库中。
Now let’s run it…
现在运行它…
Success!
成功!
Behold — Structured data! 看哪—结构化数据!That’s actually quite impressive — we’ve now gone from data on a piece of paper, to a CSV, to now knowing the schema of the data, all using serverless components. Noice.
这实际上非常令人印象深刻-我们现在已经从纸上的数据到CSV,再到现在都知道数据的模式,所有这些都使用无服务器组件。 哎呀
We’ve got this far, now it’s time to run some queries. Switching over to AWS Athena, we can run SQL queries on our data using the newly create database / tables. When we run our query, it will scan the contents of the CSV file in our S3 bucket, using the schema that the Glue crawler identified.
到此为止,现在该运行一些查询了。 切换到AWS Athena后,我们可以使用新创建的数据库/表对数据运行SQL查询。 当我们运行查询时,它将使用Glue搜寻器识别的架构扫描S3存储桶中CSV文件的内容。
Let’s see if this works… 让我们看看这是否有效…… Success! 成功!There you have it folks — turns out you can run an SQL query on a piece of paper. In the real world (or even in a futuristic cloud computing assisted version of Animal Farm) of course you would never do this with a hand/trotter drawn dataset, however the general theory and AWS services showcased could be used to query very large datasets from CSV’s / Parquet, etc — using only serverless components.
在那里,伙计们—事实证明,您可以在一张纸上运行SQL查询。 当然,在现实世界中(或什至在未来的云计算辅助版本的Animal Farm中) ,您永远都不会使用手/猪蹄绘制的数据集来执行此操作,但是所展示的一般理论和AWS服务可用于查询来自CSV / Parquet等-仅使用无服务器组件。
翻译自: https://medium.com/swlh/can-you-run-an-sql-query-on-a-piece-of-paper-using-aws-253a4a246ecf
aws waf sql注入