Merge pull request #17 from LEv145/main

Обновление структуры
This commit is contained in:
Stravnik 2022-03-28 09:47:40 +03:00 committed by GitHub
commit 88fc44dde5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 40 additions and 20 deletions

View File

@ -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
* Вы можете написать нам на почту info@toxic-repos.ru

View File

@ -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
<https://docs.github.com/en/site-policy/acceptable-use-policies/github-acceptable-use-policies#2-user-safety>

View File

@ -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](./toxic-repos.txt)
## Дополнительно
[JSON](./toxic-repos.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)
- Отправка репорта по [инструкции](HOW-TO-REPORT.md)

View File

@ -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
```

View File

@ -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:

View File

@ -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())