-
Notifications
You must be signed in to change notification settings - Fork 1
Удаление своего комментария #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
20520f5
6103ee5
63e4dcc
5f5937e
f5cb384
d14a95c
ac795cf
df5c92a
9496efb
7995cfd
71daf32
0aaf014
c4beee7
39c80a2
3c3127e
1597cee
3a28278
97ebd78
176b68c
8d2891e
9841dab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,16 +234,27 @@ async def review_comment( | |
|
||
@comment.delete("/{uuid}", response_model=StatusResponseModel) | ||
async def delete_comment( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Неправильное использование Depends There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Использование There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Проверка наличия скоупа для удаления комментариев There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Неоптимальное форматирование строки There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Добавьте аннотацию типа для параметра There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Потенциальная уязвимость при использовании There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Использование There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Переименование переменной There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Использование констант для строк There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Избыточность переменной There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Использование более информативных имен переменных There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Неправильное использование переменной There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Упрощение логики проверки наличия скоупа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Избегайте дублирования кода |
||
uuid: UUID, _=Depends(UnionAuth(scopes=["rating.comment.delete"], allow_none=False, auto_error=True)) | ||
uuid: UUID, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Переименование переменной для ясности There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Некорректное использование переменной There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Логическая ошибка в проверке прав |
||
user=Depends(UnionAuth(auto_error=True, allow_none=False)), | ||
): | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Логическая ошибка в проверке прав There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Неправильное использование There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Логическая ошибка в проверке прав доступа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Улучшение читаемости кода There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Неэффективное использование памяти There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Дублирование кода |
||
Scopes: `["rating.comment.delete"]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Потенциальная ошибка при отсутствии прав There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Неэффективный запрос к базе данных There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Упростите проверку наличия скоупа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Логическая ошибка в проверке прав There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Использование констант для строк There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Избыточная проверка There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Логическая ошибка при проверке прав |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Потенциальная утечка ресурсов There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Использование запроса к БД для получения комментария There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Использование более конкретного имени переменной There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Неправильное использование Depends There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Переменная There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Использование имени переменной |
||
Удаляет комментарий по его UUID в базе данных RatingAPI | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Потенциальная уязвимость There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Нарушение стилевых соглашений There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Неправильное использование зависимостей There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Проверка наличия скоупа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Логическая ошибка в проверке прав There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Неправильное именование переменной There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Использование переменной для хранения результата проверки скоупов There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Форматирование кода There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Использование более информативных имен переменных There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Использование list comprehension для проверки скоупа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Неправильное использование переменной |
||
""" | ||
check_comment = Comment.get(session=db.session, id=uuid) | ||
if check_comment is None: | ||
comment = Comment.get(uuid, session=db.session) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Форматирование строки |
||
if comment is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Дублирование кода при возврате ответа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Неправильное форматирование возвращаемого значения |
||
raise ObjectNotFound(Comment, uuid) | ||
# Наличие скоупа для удаления любых комментариев | ||
has_delete_scope = "rating.comment.delete" in [scope['name'] for scope in user.get('session_scopes', [])] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Неэффективный способ проверки наличия скоупа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Условие проверки прав обычного пользователя There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Отсутствие обработки исключений при запросе к базе данных There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Логическая ошибка в условии There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Проверка наличия комментария |
||
# Если нет привилегии - проверяем права обычного пользователя | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Упростите условие проверки прав обычного пользователя There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Логическая ошибка в условии There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Дублирование логики проверки прав |
||
if not has_delete_scope: | ||
if comment.is_anonymous: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Логическая ошибка в условии проверки прав There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Проверка наличия комментария не эффективна There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Проверка анонимности комментария There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Удаление избыточного кода |
||
raise ForbiddenAction(Comment) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Логическая ошибка в проверке прав доступа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Проверка прав доступа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Улучшение читаемости кода |
||
|
||
if not has_delete_scope or comment.user_id != user.id: | ||
raise ForbiddenAction(Comment) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Улучшение читаемости кода |
||
Comment.delete(session=db.session, id=uuid) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [СТИЛЬ] Форматирование строки возврата There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Логика проверки прав доступа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Логика проверки прав доступа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [КРИТИЧНО] Проверка прав доступа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Проверка на удаление комментария |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ВАЖНО] Логика проверки прав доступа сложна и трудночитаема There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [УЛУЧШЕНИЕ] Удаление избыточного кода |
||
return StatusResponseModel( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[КРИТИЧНО] Потенциальное исключение при отсутствии комментария