From 2f2a0e8df40a5340c987f39776e3f77f4ea75355 Mon Sep 17 00:00:00 2001 From: lev Date: Sun, 27 Mar 2022 14:31:12 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D1=85?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20data=20?= =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D1=8B=20=D0=BF=D1=83?= =?UTF-8?q?=D1=82=D0=B8=20=D0=B2=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82?= =?UTF-8?q?=D0=B0=D1=85=20=D0=9E=D1=82=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D1=8B=20readme=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BF=D0=BE=20=D0=BB=D0=B8=D0=BD?= =?UTF-8?q?=D1=82=D0=B5=D1=80=D1=83=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=20toxic-repos.rst(=D0=92=D0=BE=D0=B7=D0=BC=D0=BE?= =?UTF-8?q?=D0=B6=D0=BD=D0=BE=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=83=D1=8E)=20=D0=B2=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HOW-TO-ADD.md | 6 +++-- HOW-TO-REPORT.md | 8 ++++--- README.md | 21 ++++++++++++------ {csv => data/csv}/toxic-repos.csv | 0 .../json/toxic-repos.json | 0 {sqlite => data/sqlite}/toxic-repos.sqlite3 | Bin toxic-repos.txt => data/txt/toxic-repos.txt | 0 scripts/README.md | 2 +- scripts/converter.py | 15 ++++++++----- scripts/generate_rst_from_sqlite.py | 8 +++++-- 10 files changed, 40 insertions(+), 20 deletions(-) rename {csv => data/csv}/toxic-repos.csv (100%) rename toxic-repos.json => data/json/toxic-repos.json (100%) rename {sqlite => data/sqlite}/toxic-repos.sqlite3 (100%) rename toxic-repos.txt => data/txt/toxic-repos.txt (100%) diff --git a/HOW-TO-ADD.md b/HOW-TO-ADD.md index 6d82560..1d0824e 100644 --- a/HOW-TO-ADD.md +++ b/HOW-TO-ADD.md @@ -1,5 +1,7 @@ # Как добавить информацию в список или удалить её из него -* Вы можете создать Pull request для файла [`toxic-repos.txt`](./toxic-repos.txt) +## Интсрукция + +* Вы можете создать Pull request для файла [`toxic-repos.txt`](./data/txt/toxic-repos.txt) * Вы можете написать в наш [Телеграм чат](https://t.me/toxic_repos) -* Вы можете написать нам на почту info@toxic-repos.ru \ No newline at end of file +* Вы можете написать нам на почту info@toxic-repos.ru diff --git a/HOW-TO-REPORT.md b/HOW-TO-REPORT.md index e890e7c..961773d 100644 --- a/HOW-TO-REPORT.md +++ b/HOW-TO-REPORT.md @@ -1,8 +1,10 @@ -# Подробная инструкция для составления жалобы на репозитории +# Как сделать репорт + +## Инструкция 1. Нажать Block or Report на странице пользователя под аватаркой. 2. Выбрать «Report Abuse». -3. Выбрать: I want to report harmful code, such as malware, phishing, or cryptocurrency abuse. +3. Выбрать: I want to report harmful code, such as malware, phishing, or cryptocurrency abuse. 4. Выбрать: I want to report malware. 5. В описании указать: @@ -11,4 +13,4 @@ This repo of the user: <Ссылка на профиль пользовател contains code to organize DOS attacks to specific resources listed in: <Ссылка на конкретный файл или на сам репозиторий> According to GitHub acceptable use policies, unlawful content is now allowed: -https://docs.github.com/en/site-policy/acceptable-use-policies/github-acceptable-use-policies#2-user-safety \ No newline at end of file + diff --git a/README.md b/README.md index 5fd435b..2ea1ac8 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,31 @@ # toxic-repos +## Информация + В последнее время участились случаи добавления в популярные Open Source проекты кода разной степени опасности. Это может нести угрозу людям, а также подрывает доверие к Open Source комьюнити и Open Source как таковому. +[Список репозиториев](toxic-repos.rst) + [:link:](https://toxic-repos.ru/) | [:speech_balloon:](https://t.me/toxic_repos) | [:email:](info@toxic-repos.ru) -# Дополнительно -[TXT](./clean.txt) +## Дополнительно -[JSON](./clean.json) +[TXT](data/txt/toxic-repos.txt) -[SQLite](sqlite/toxic-repos.sqlite3) +[JSON](data/json/toxic-repos.json) + +[SQLite](data/sqlite/toxic-repos.sqlite3) + +## Статистика -# Статистика Опасных репозиториев: 227 -# Рекомендации +## Рекомендации + - Изоляция сборки в контейнерах, в том числе и для промежуточных сборок на машинах разработчиков. - Форки всех библиотек (по возможности) и контейнеров к себе. - Зеркалирование репозиториев пакетов. - Включение в CI как минимум поиска по ключевым словам, UTF символам с изображением украинского флага и сравнение списка файлов с вайтлистом. - Ресерч по инструментам анализа кода. -- Отправка репорта по [инструкции](./HOW-TO-REPORT.md) \ No newline at end of file +- Отправка репорта по [инструкции](HOW-TO-REPORT.md) diff --git a/csv/toxic-repos.csv b/data/csv/toxic-repos.csv similarity index 100% rename from csv/toxic-repos.csv rename to data/csv/toxic-repos.csv diff --git a/toxic-repos.json b/data/json/toxic-repos.json similarity index 100% rename from toxic-repos.json rename to data/json/toxic-repos.json diff --git a/sqlite/toxic-repos.sqlite3 b/data/sqlite/toxic-repos.sqlite3 similarity index 100% rename from sqlite/toxic-repos.sqlite3 rename to data/sqlite/toxic-repos.sqlite3 diff --git a/toxic-repos.txt b/data/txt/toxic-repos.txt similarity index 100% rename from toxic-repos.txt rename to data/txt/toxic-repos.txt diff --git a/scripts/README.md b/scripts/README.md index 89dbaa8..ccaee5d 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -4,7 +4,7 @@ ```bash python3 -m venv scripts/.env -source scripts/.env/bin/activate # Bash, see https://docs.python.org/3/library/venv.html +source scripts/.env/bin/activate # For bash, see: https://docs.python.org/3/library/venv.html python3 -m pip install --upgrade pip python3 -m pip install -r scripts/requirements.txt ``` diff --git a/scripts/converter.py b/scripts/converter.py index 7e58cd4..bf0d061 100644 --- a/scripts/converter.py +++ b/scripts/converter.py @@ -3,9 +3,14 @@ import sys import sqlite3 import json +from pathlib import Path + + +INPUT_FILE_PATH = Path("data/txt/toxic-repos.txt") +OUT_FILE_PATH = Path("data/json/toxic-repos.json") +DATABASE_PATH = Path("data/sqlite/toxic-repos.sqlite3") + -infile = "../toxic-repos.txt" -outfile = "../toxic-repos.json" # output JSON format (array of dicts): #[ # { @@ -33,7 +38,7 @@ TABLE_CREATION_QUERY = """ toxics_array = [] fields = ["datetime", "problemtype", "productname", "url", "comment"] -with open(infile, 'r', encoding='utf-8') as fh: +with open(INPUT_FILE_PATH, 'r', encoding='utf-8') as fh: print("Читаем txt файл", file=sys.stderr) # not using `logging` or `loguru` module to avoid need for dependency for line in fh: @@ -41,14 +46,14 @@ with open(infile, 'r', encoding='utf-8') as fh: print(f'Прочитана и распознана строка: {description}', file=sys.stderr) toxics_array.append(dict(zip(fields, description))) -with open(outfile, 'w', encoding='utf-8') as out_file: +with open(OUT_FILE_PATH, 'w', encoding='utf-8') as out_file: print("Пишем json файл", file=sys.stderr) json.dump(toxics_array, out_file, indent=2) db = None # default value for case when DB failde to be opened try: print("Соединяемся с SQLite базой", file=sys.stderr) - db = sqlite3.connect("../sqlite/toxic-repos.sqlite3") + db = sqlite3.connect(DATABASE_PATH) c = db.cursor() c.execute(TABLE_CREATION_QUERY) for one_txc in toxics_array: diff --git a/scripts/generate_rst_from_sqlite.py b/scripts/generate_rst_from_sqlite.py index 619e379..5787cc6 100755 --- a/scripts/generate_rst_from_sqlite.py +++ b/scripts/generate_rst_from_sqlite.py @@ -9,6 +9,10 @@ from dataclasses import dataclass from rst_builder import RSTMaker, RSTBuilder +DATABASE_PATH = Path("data/sqlite/toxic-repos.sqlite3") +OUT_FILE_PATH = Path("toxic-repos.rst") + + @dataclass class DataModel(): data: str @@ -18,7 +22,7 @@ class DataModel(): def main() -> None: - connection = sqlite3.connect(Path("sqlite/toxic-repos.sqlite3")) + connection = sqlite3.connect(DATABASE_PATH) cursor = connection.cursor() data: t.Dict[str, t.List[DataModel]] = defaultdict(list) @@ -60,7 +64,7 @@ def main() -> None: result.add_text(data_model.description) result.add_indents(2) - with open("toxic-repos.rst", "w") as fp: + with open(OUT_FILE_PATH, "w") as fp: fp.write(result.get_result())