Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def store(
form: HttpServerCreateForm,
http_server_repo: HttpServerRepo = Depends(HttpServerRepo()),
token: TokenPayload = Depends(ScopedTo("http-server:create")),
):
if http_server_repo.exists(name=form.name.lower()):
abort_for_input("name", "Server name already taken")
data = only(dict(form), ["name"])
data["name"] = data["name"].lower()
item = http_server_repo.create(data).data()
return HttpServerResponse(http_server=item)
def get_log(
project: str,
uid: str,
size: int = -1,
offset: int = 0,
tag: str = "",
db_session: Session = Depends(deps.get_db_session)):
out, status = crud.Logs.get_log(db_session, project, uid, size, offset)
return Response(content=out, media_type="text/plain", headers={"pod_status": status})
async def index(
zone_id: int,
sort_qs: SortQS = Depends(SortQS),
pagination: PaginationQS = Depends(PaginationQS),
dns_record_repo: DnsRecordRepo = Depends(DnsRecordRepo()),
zone_repo: ZoneRepo = Depends(ZoneRepo()),
token: TokenPayload = Depends(ScopedTo("dns-record:list")),
includes: List[str] = Query(None),
):
zone_repo.exists(id=zone_id, or_fail=True)
includes = only(includes, ["zone"], values=True)
pg, items = (
dns_record_repo.loads("zone")
.sort(sort_qs)
.filter_by(zone_id=zone_id)
.paginate(pagination)
.includes(includes)
def del_runs(
project: str = None,
name: str = None,
labels: List[str] = Query([], alias='label'),
state: str = None,
days_ago: int = 0,
db_session: Session = Depends(deps.get_db_session)):
get_db().del_runs(db_session, name, project, labels, state, days_ago)
return {}
def check_comment_modification_permissions(
comment: Comment = Depends(get_comment_by_id_from_path),
user: User = Depends(authentication.get_current_user_authorizer()),
) -> None:
if not check_user_can_modify_comment(comment, user):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=strings.USER_IS_NOT_AUTHOR_OF_ARTICLE,
)
def test_email(
email_to: EmailStr, current_user: UserInDB = Depends(get_current_active_superuser)
):
"""
Test emails.
"""
send_test_email(email_to=email_to)
return {"msg": "Test email sent"}
def read_user(user_id: int, db: Session = Depends(get_db)):
user = get_user(db, user_id=user_id)
return user
@router.get('/group/', dependencies=[Depends(Etag(get_etag))])
@router.get('/group/{group_name}', dependencies=[Depends(Etag(get_etag))])
async def group(request: Request, response: Response, group_name: Optional[str] = None) -> Response:
global state
if group_name is not None:
res = []
for s in state.sources.values():
for k, p in sorted(s.packages.items()):
if group_name in p.groups:
res.append(p)
return templates.TemplateResponse("group.html", {
"request": request,
"name": group_name,
"packages": res,
}, headers=dict(response.headers))
async def follow_for_user(
profile: Profile = Depends(get_profile_by_username_from_path),
user: User = Depends(get_current_user_authorizer()),
profiles_repo: ProfilesRepository = Depends(get_repository(ProfilesRepository)),
) -> ProfileInResponse:
if user.username == profile.username:
raise HTTPException(
status_code=HTTP_400_BAD_REQUEST, detail=strings.UNABLE_TO_FOLLOW_YOURSELF
)
if profile.following:
raise HTTPException(
status_code=HTTP_400_BAD_REQUEST, detail=strings.USER_IS_ALREADY_FOLLOWED
)
await profiles_repo.add_user_into_followers(
target_user=profile, requested_user=user
)
async def read_items(commons=Depends(CommonQueryParams)):
response = {}
if commons.q:
response.update({"q": commons.q})
items = fake_items_db[commons.skip : commons.skip + commons.limit]
response.update({"items": items})
return response