code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def purge(tag):
"""
Issues a purge, clearing all cached objects associated with the tag
from the cache.
""" |
Issues a purge, clearing all cached objects associated with the tag
from the cache.
| purge | python | pypi/warehouse | warehouse/legacy/api/xmlrpc/cache/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/legacy/api/xmlrpc/cache/interfaces.py | Apache-2.0 |
def purge_tags(tags):
"""
Issues a purge, clearing all cached objects associated with each tag
in the iterable tags.
""" |
Issues a purge, clearing all cached objects associated with each tag
in the iterable tags.
| purge_tags | python | pypi/warehouse | warehouse/legacy/api/xmlrpc/cache/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/legacy/api/xmlrpc/cache/interfaces.py | Apache-2.0 |
def find_from_raw(raw_macaroon):
"""
Returns a macaroon model from the DB from a raw macaroon, or raises
InvalidMacaroon if not found or for malformed macaroons.
""" |
Returns a macaroon model from the DB from a raw macaroon, or raises
InvalidMacaroon if not found or for malformed macaroons.
| find_from_raw | python | pypi/warehouse | warehouse/macaroons/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/interfaces.py | Apache-2.0 |
def find_macaroon(macaroon_id):
"""
Returns a macaroon model from the DB by its identifier.
Returns None if no macaroon has the given ID.
""" |
Returns a macaroon model from the DB by its identifier.
Returns None if no macaroon has the given ID.
| find_macaroon | python | pypi/warehouse | warehouse/macaroons/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/interfaces.py | Apache-2.0 |
def find_userid(raw_macaroon):
"""
Returns the id of the user associated with the given raw (serialized)
macaroon.
""" |
Returns the id of the user associated with the given raw (serialized)
macaroon.
| find_userid | python | pypi/warehouse | warehouse/macaroons/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/interfaces.py | Apache-2.0 |
def verify(raw_macaroon, request, context, permission):
"""
Returns True if the given raw (serialized) macaroon is
valid for the request, context, and requested permission.
Raises InvalidMacaroonError if the macaroon is not valid.
""" |
Returns True if the given raw (serialized) macaroon is
valid for the request, context, and requested permission.
Raises InvalidMacaroonError if the macaroon is not valid.
| verify | python | pypi/warehouse | warehouse/macaroons/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/interfaces.py | Apache-2.0 |
def create_macaroon(
location,
description,
scopes,
*,
user_id=None,
oidc_publisher_id=None,
additional=None
):
"""
Returns a tuple of a new raw (serialized) macaroon and its DB model.
The description provided is not embedded into the m... |
Returns a tuple of a new raw (serialized) macaroon and its DB model.
The description provided is not embedded into the macaroon, only stored
in the DB model.
An associated identity (either a user or macaroon, by ID) must be specified.
| create_macaroon | python | pypi/warehouse | warehouse/macaroons/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/interfaces.py | Apache-2.0 |
def delete_macaroon(macaroon_id):
"""
Deletes a macaroon from the DB by its identifier.
""" |
Deletes a macaroon from the DB by its identifier.
| delete_macaroon | python | pypi/warehouse | warehouse/macaroons/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/interfaces.py | Apache-2.0 |
def get_macaroon_by_description(user_id, description):
"""
Returns a macaroon model from the DB with the given description,
if one exists for the given user.
Returns None if the user doesn't have a macaroon with this description.
""" |
Returns a macaroon model from the DB with the given description,
if one exists for the given user.
Returns None if the user doesn't have a macaroon with this description.
| get_macaroon_by_description | python | pypi/warehouse | warehouse/macaroons/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/interfaces.py | Apache-2.0 |
def _extract_basic_macaroon(auth):
"""
A helper function for extracting a macaroon from a
HTTP Basic Authentication-style header.
Returns None if the header doesn't contain a structurally
valid macaroon, or the candidate (not yet verified) macaroon
in a serialized form.
"""
try:
... |
A helper function for extracting a macaroon from a
HTTP Basic Authentication-style header.
Returns None if the header doesn't contain a structurally
valid macaroon, or the candidate (not yet verified) macaroon
in a serialized form.
| _extract_basic_macaroon | python | pypi/warehouse | warehouse/macaroons/security_policy.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/security_policy.py | Apache-2.0 |
def _extract_http_macaroon(request):
"""
A helper function for the extraction of HTTP Macaroon from a given request.
Returns either a None if no macaroon could be found, or the string
that represents our serialized macaroon.
"""
authorization = request.headers.get("Authorization")
if not aut... |
A helper function for the extraction of HTTP Macaroon from a given request.
Returns either a None if no macaroon could be found, or the string
that represents our serialized macaroon.
| _extract_http_macaroon | python | pypi/warehouse | warehouse/macaroons/security_policy.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/security_policy.py | Apache-2.0 |
def _extract_raw_macaroon(prefixed_macaroon: str | None) -> str | None:
"""
Returns the base64-encoded macaroon component of a PyPI macaroon,
dropping the prefix.
Returns None if the macaroon is None, has no prefix, or has the
wrong prefix.
"""
if prefixed_macaroon is None:
return N... |
Returns the base64-encoded macaroon component of a PyPI macaroon,
dropping the prefix.
Returns None if the macaroon is None, has no prefix, or has the
wrong prefix.
| _extract_raw_macaroon | python | pypi/warehouse | warehouse/macaroons/services.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/services.py | Apache-2.0 |
def deserialize_raw_macaroon(raw_macaroon: str | None) -> pymacaroons.Macaroon:
"""
Returns a pymacaroons.Macaroon instance from a raw (serialized) macaroon.
"""
raw_macaroon = _extract_raw_macaroon(raw_macaroon)
if raw_macaroon is None:
raise InvalidMacaroonError("malformed or nonexistent ... |
Returns a pymacaroons.Macaroon instance from a raw (serialized) macaroon.
| deserialize_raw_macaroon | python | pypi/warehouse | warehouse/macaroons/services.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/services.py | Apache-2.0 |
def find_from_raw(self, raw_macaroon: str) -> Macaroon:
"""
Returns a DB macaroon matching the input, or raises InvalidMacaroonError
"""
m = deserialize_raw_macaroon(raw_macaroon)
try:
identifier = m.identifier.decode()
except UnicodeDecodeError:
... |
Returns a DB macaroon matching the input, or raises InvalidMacaroonError
| find_from_raw | python | pypi/warehouse | warehouse/macaroons/services.py | https://github.com/pypi/warehouse/blob/master/warehouse/macaroons/services.py | Apache-2.0 |
def organization_owners(request, organization):
"""Return all users who are owners of the organization."""
owner_roles = (
request.db.query(User.id)
.join(OrganizationRole.user)
.filter(
OrganizationRole.role_name == OrganizationRoleType.Owner,
OrganizationRole.or... | Return all users who are owners of the organization. | organization_owners | python | pypi/warehouse | warehouse/manage/views/organizations.py | https://github.com/pypi/warehouse/blob/master/warehouse/manage/views/organizations.py | Apache-2.0 |
def organization_managers(request, organization):
"""Return all users who are managers of the organization."""
manager_roles = (
request.db.query(User.id)
.join(OrganizationRole.user)
.filter(
OrganizationRole.role_name == OrganizationRoleType.Manager,
Organizatio... | Return all users who are managers of the organization. | organization_managers | python | pypi/warehouse | warehouse/manage/views/organizations.py | https://github.com/pypi/warehouse/blob/master/warehouse/manage/views/organizations.py | Apache-2.0 |
def organization_members(request, organization):
"""Return all users who are members of the organization."""
member_roles = (
request.db.query(User.id)
.join(OrganizationRole.user)
.filter(
OrganizationRole.role_name == OrganizationRoleType.Member,
OrganizationRol... | Return all users who are members of the organization. | organization_members | python | pypi/warehouse | warehouse/manage/views/organizations.py | https://github.com/pypi/warehouse/blob/master/warehouse/manage/views/organizations.py | Apache-2.0 |
def user_organizations(request):
"""Return all the organizations for which the user has a privileged role."""
organizations_managed = (
request.db.query(Organization.id)
.join(OrganizationRole.organization)
.filter(
OrganizationRole.role_name == OrganizationRoleType.Manager,
... | Return all the organizations for which the user has a privileged role. | user_organizations | python | pypi/warehouse | warehouse/manage/views/view_helpers.py | https://github.com/pypi/warehouse/blob/master/warehouse/manage/views/view_helpers.py | Apache-2.0 |
def user_projects(request):
"""Return all the projects for which the user is a sole owner"""
projects_owned = (
request.db.query(Project.id.label("id"))
.join(Role.project)
.filter(Role.role_name == "Owner", Role.user == request.user)
)
projects_collaborator = (
request.... | Return all the projects for which the user is a sole owner | user_projects | python | pypi/warehouse | warehouse/manage/views/view_helpers.py | https://github.com/pypi/warehouse/blob/master/warehouse/manage/views/view_helpers.py | Apache-2.0 |
def gauge(metric, value, tags=None, sample_rate=1):
"""
Record the value of a gauge, optionally setting a list of tags and a
sample rate.
""" |
Record the value of a gauge, optionally setting a list of tags and a
sample rate.
| gauge | python | pypi/warehouse | warehouse/metrics/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/metrics/interfaces.py | Apache-2.0 |
def increment(metric, value=1, tags=None, sample_rate=1):
"""
Increment a counter, optionally setting a value, tags and a sample
rate.
""" |
Increment a counter, optionally setting a value, tags and a sample
rate.
| increment | python | pypi/warehouse | warehouse/metrics/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/metrics/interfaces.py | Apache-2.0 |
def decrement(metric, value=1, tags=None, sample_rate=1):
"""
Decrement a counter, optionally setting a value, tags and a sample
rate.
""" |
Decrement a counter, optionally setting a value, tags and a sample
rate.
| decrement | python | pypi/warehouse | warehouse/metrics/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/metrics/interfaces.py | Apache-2.0 |
def histogram(metric, value, tags=None, sample_rate=1):
"""
Sample a histogram value, optionally setting tags and a sample rate.
""" |
Sample a histogram value, optionally setting tags and a sample rate.
| histogram | python | pypi/warehouse | warehouse/metrics/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/metrics/interfaces.py | Apache-2.0 |
def distribution(metric, value, tags=None, sample_rate=1):
"""
Send a global distribution value, optionally setting tags and a sample rate.
""" |
Send a global distribution value, optionally setting tags and a sample rate.
| distribution | python | pypi/warehouse | warehouse/metrics/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/metrics/interfaces.py | Apache-2.0 |
def timing(metric, value, tags=None, sample_rate=1):
"""
Record a timing, optionally setting tags and a sample rate.
""" |
Record a timing, optionally setting tags and a sample rate.
| timing | python | pypi/warehouse | warehouse/metrics/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/metrics/interfaces.py | Apache-2.0 |
def timed(metric=None, tags=None, sample_rate=1, use_ms=None):
"""
A decorator or context manager that will measure the distribution of a
function's/context's run time. Optionally specify a list of tags or a
sample rate. If the metric is not defined as a decorator, the module
nam... |
A decorator or context manager that will measure the distribution of a
function's/context's run time. Optionally specify a list of tags or a
sample rate. If the metric is not defined as a decorator, the module
name and function name will be used. The metric is required as a context
... | timed | python | pypi/warehouse | warehouse/metrics/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/metrics/interfaces.py | Apache-2.0 |
def downgrade():
"""
Drop trigger and function that synchronize `releases`.
"""
op.execute("DROP TRIGGER releases_requires_python ON releases")
op.execute("DROP FUNCTION update_release_files_requires_python()")
op.drop_column("release_files", "requires_python") |
Drop trigger and function that synchronize `releases`.
| downgrade | python | pypi/warehouse | warehouse/migrations/versions/be4cf6b58557_add_requires_python_to_release_files.py | https://github.com/pypi/warehouse/blob/master/warehouse/migrations/versions/be4cf6b58557_add_requires_python_to_release_files.py | Apache-2.0 |
def record_observation(
self,
*,
request: Request,
kind: ObservationKind,
actor: User, # TODO: Expand type as we add more HasObserver models
summary: str,
payload: dict,
):
"""
Record an observation on the related model.
"""
if... |
Record an observation on the related model.
| record_observation | python | pypi/warehouse | warehouse/observations/models.py | https://github.com/pypi/warehouse/blob/master/warehouse/observations/models.py | Apache-2.0 |
def report_observation_to_helpscout(task, request: Request, model_id: UUID) -> None:
"""
Report an Observation to HelpScout for further tracking.
"""
# Fetch the Observation from the database
model = request.db.get(Observation, model_id)
# Check to see if this ObservationKind should be sent
... |
Report an Observation to HelpScout for further tracking.
| report_observation_to_helpscout | python | pypi/warehouse | warehouse/observations/tasks.py | https://github.com/pypi/warehouse/blob/master/warehouse/observations/tasks.py | Apache-2.0 |
def evaluate_project_for_quarantine(
task: WarehouseTask, request: Request, observation_id: UUID
) -> None:
"""
Conditionally quarantine a Project for Admin review.
Conditions must be met:
- ObservationKind is IsMalware
- Observed Project is not already quarantined
- Observed Project has a... |
Conditionally quarantine a Project for Admin review.
Conditions must be met:
- ObservationKind is IsMalware
- Observed Project is not already quarantined
- Observed Project has at least 2 Observations, at least 1 by `User.is_observer`
| evaluate_project_for_quarantine | python | pypi/warehouse | warehouse/observations/tasks.py | https://github.com/pypi/warehouse/blob/master/warehouse/observations/tasks.py | Apache-2.0 |
def reify_pending_publisher(
pending_publisher: PendingOIDCPublisher, project: Project
):
"""
Reify the given pending `PendingOIDCPublisher` into an `OIDCPublisher`,
adding it to the given project (presumed newly created) in the process.
Returns the reified publisher.
... |
Reify the given pending `PendingOIDCPublisher` into an `OIDCPublisher`,
adding it to the given project (presumed newly created) in the process.
Returns the reified publisher.
| reify_pending_publisher | python | pypi/warehouse | warehouse/oidc/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/interfaces.py | Apache-2.0 |
def _store_keyset(self, keys):
"""
Store the given keyset for the given publisher, setting the timeout key
in the process.
"""
with redis.StrictRedis.from_url(self.cache_url) as r:
r.set(self._publisher_jwk_key, json.dumps(keys))
r.setex(self._publisher_t... |
Store the given keyset for the given publisher, setting the timeout key
in the process.
| _store_keyset | python | pypi/warehouse | warehouse/oidc/services.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/services.py | Apache-2.0 |
def _get_keyset(self):
"""
Return the cached keyset for the given publisher, or an empty
keyset if no keys are currently cached.
"""
with redis.StrictRedis.from_url(self.cache_url) as r:
keys = r.get(self._publisher_jwk_key)
timeout = bool(r.exists(self._... |
Return the cached keyset for the given publisher, or an empty
keyset if no keys are currently cached.
| _get_keyset | python | pypi/warehouse | warehouse/oidc/services.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/services.py | Apache-2.0 |
def _refresh_keyset(self):
"""
Attempt to refresh the keyset from the OIDC publisher, assuming no
timeout is in effect.
Returns the refreshed keyset, or the cached keyset if a timeout is
in effect.
Returns the cached keyset on any publisher access or format errors.
... |
Attempt to refresh the keyset from the OIDC publisher, assuming no
timeout is in effect.
Returns the refreshed keyset, or the cached keyset if a timeout is
in effect.
Returns the cached keyset on any publisher access or format errors.
| _refresh_keyset | python | pypi/warehouse | warehouse/oidc/services.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/services.py | Apache-2.0 |
def _get_key(self, key_id):
"""
Return a JWK for the given key ID, or None if the key can't be found
in this publisher's keyset.
"""
keyset, _ = self._get_keyset()
if key_id not in keyset:
keyset = self._refresh_keyset()
if key_id not in keyset:
... |
Return a JWK for the given key ID, or None if the key can't be found
in this publisher's keyset.
| _get_key | python | pypi/warehouse | warehouse/oidc/services.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/services.py | Apache-2.0 |
def store_jwt_identifier(self, jti: str, expiration: int) -> None:
"""
Store the JTI with its expiration date if the key does not exist.
"""
with redis.StrictRedis.from_url(self.cache_url) as r:
# Defensive: to prevent races, we expire the JTI slightly after
# the... |
Store the JTI with its expiration date if the key does not exist.
| store_jwt_identifier | python | pypi/warehouse | warehouse/oidc/services.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/services.py | Apache-2.0 |
def find_publisher(
self, signed_claims: SignedClaims, *, pending: bool = False
) -> OIDCPublisher | PendingOIDCPublisher:
"""Returns a publisher for the given claims, or raises an error."""
metrics_tags = [f"publisher:{self.publisher}"]
self.metrics.increment(
"warehouse... | Returns a publisher for the given claims, or raises an error. | find_publisher | python | pypi/warehouse | warehouse/oidc/services.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/services.py | Apache-2.0 |
def delete_expired_oidc_macaroons(request):
"""
Purge all API tokens minted using OIDC Trusted Publishing with a creation time
more than 1 day ago. Since OIDC-minted macaroons expire 15 minutes after
creation, this task cleans up tokens that expired several hours ago and that
have accumulated since ... |
Purge all API tokens minted using OIDC Trusted Publishing with a creation time
more than 1 day ago. Since OIDC-minted macaroons expire 15 minutes after
creation, this task cleans up tokens that expired several hours ago and that
have accumulated since the last time this task was run.
| delete_expired_oidc_macaroons | python | pypi/warehouse | warehouse/oidc/tasks.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/tasks.py | Apache-2.0 |
def verify_url_from_reference(*, reference_url: str, url: str) -> bool:
"""
Verify a given URL against a reference URL.
This method checks that both URLs have:
- the same scheme
- the same authority
Finally, that the URL is a sub-path of the reference.
"""
reference_uri = rfc39... |
Verify a given URL against a reference URL.
This method checks that both URLs have:
- the same scheme
- the same authority
Finally, that the URL is a sub-path of the reference.
| verify_url_from_reference | python | pypi/warehouse | warehouse/oidc/urls.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/urls.py | Apache-2.0 |
def find_publisher_by_issuer(
session, issuer_url: str, signed_claims: SignedClaims, *, pending: bool = False
) -> OIDCPublisher | PendingOIDCPublisher:
"""
Given an OIDC issuer URL and a dictionary of claims that have been verified
for a token from that OIDC issuer, retrieve either an `OIDCPublisher` r... |
Given an OIDC issuer URL and a dictionary of claims that have been verified
for a token from that OIDC issuer, retrieve either an `OIDCPublisher` registered
to one or more projects or a `PendingOIDCPublisher`, varying with the
`pending` parameter.
Returns `None` if no publisher can be found.
| find_publisher_by_issuer | python | pypi/warehouse | warehouse/oidc/utils.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/utils.py | Apache-2.0 |
def is_from_reusable_workflow(
publisher: OIDCPublisher | None, claims: SignedClaims
) -> bool:
"""Detect if the claims are originating from a reusable workflow."""
if not isinstance(publisher, GitHubPublisher):
return False
job_workflow_ref = claims.get("job_workflow_ref")
workflow_ref = c... | Detect if the claims are originating from a reusable workflow. | is_from_reusable_workflow | python | pypi/warehouse | warehouse/oidc/views.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/views.py | Apache-2.0 |
def should_send_environment_warning_email(
publisher: OIDCPublisher, claims: SignedClaims
) -> bool:
"""
Determine if the claims contain an environment but the publisher doesn't
If the publisher does not have an environment configured but the claims
contain one, it means the project can easily impr... |
Determine if the claims contain an environment but the publisher doesn't
If the publisher does not have an environment configured but the claims
contain one, it means the project can easily improve security by constraining
the Trusted Publisher to only that environment.
This currently only applie... | should_send_environment_warning_email | python | pypi/warehouse | warehouse/oidc/views.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/views.py | Apache-2.0 |
def _lookup_organization(self, org_url_name: str) -> None:
"""Make gql API call to the ActiveState API to check if the organization
exists"""
def process_org_response(response: GqlResponse) -> None:
data = response.get("data")
if data and not data.get("organizations"):
... | Make gql API call to the ActiveState API to check if the organization
exists | _lookup_organization | python | pypi/warehouse | warehouse/oidc/forms/activestate.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/forms/activestate.py | Apache-2.0 |
def _lookup_actor(self, actor: str) -> UserResponse:
"""Make gql API call to the ActiveState API to check if the actor/username
exists and return the associated user id"""
def process_actor_response(response: GqlResponse) -> UserResponse:
users = response.get("data", {}).get("users"... | Make gql API call to the ActiveState API to check if the actor/username
exists and return the associated user id | _lookup_actor | python | pypi/warehouse | warehouse/oidc/forms/activestate.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/forms/activestate.py | Apache-2.0 |
def reify(self, session):
"""
Returns a `ActiveStatePublisher` for this `PendingActiveStatePublisher`,
deleting the `PendingActiveStatePublisher` in the process.
"""
# Check if the publisher already exists. Return it if it does.
maybe_publisher = (
session.qu... |
Returns a `ActiveStatePublisher` for this `PendingActiveStatePublisher`,
deleting the `PendingActiveStatePublisher` in the process.
| reify | python | pypi/warehouse | warehouse/oidc/models/activestate.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/activestate.py | Apache-2.0 |
def verify_url(self, url: str):
"""
Verify a given URL against this GitHub's publisher information
In addition to the generic Trusted Publisher verification logic in
the parent class, the GitHub Trusted Publisher allows URLs hosted
on `github.io` for the configured repository, i... |
Verify a given URL against this GitHub's publisher information
In addition to the generic Trusted Publisher verification logic in
the parent class, the GitHub Trusted Publisher allows URLs hosted
on `github.io` for the configured repository, i.e:
`https://${OWNER}.github.io/${R... | verify_url | python | pypi/warehouse | warehouse/oidc/models/github.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/github.py | Apache-2.0 |
def reify(self, session):
"""
Returns a `GitHubPublisher` for this `PendingGitHubPublisher`,
deleting the `PendingGitHubPublisher` in the process.
"""
maybe_publisher = (
session.query(GitHubPublisher)
.filter(
GitHubPublisher.repository_n... |
Returns a `GitHubPublisher` for this `PendingGitHubPublisher`,
deleting the `PendingGitHubPublisher` in the process.
| reify | python | pypi/warehouse | warehouse/oidc/models/github.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/github.py | Apache-2.0 |
def verify_url(self, url: str):
"""
Verify a given URL against this GitLab's publisher information
In addition to the generic Trusted Publisher verification logic in
the parent class, the GitLab Trusted Publisher ignores the suffix `.git`
in repo URLs, since `gitlab.com/org/repo... |
Verify a given URL against this GitLab's publisher information
In addition to the generic Trusted Publisher verification logic in
the parent class, the GitLab Trusted Publisher ignores the suffix `.git`
in repo URLs, since `gitlab.com/org/repo.git` always redirects to
`gitlab.c... | verify_url | python | pypi/warehouse | warehouse/oidc/models/gitlab.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/gitlab.py | Apache-2.0 |
def reify(self, session):
"""
Returns a `GitLabPublisher` for this `PendingGitLabPublisher`,
deleting the `PendingGitLabPublisher` in the process.
"""
maybe_publisher = (
session.query(GitLabPublisher)
.filter(
GitLabPublisher.namespace ==... |
Returns a `GitLabPublisher` for this `PendingGitLabPublisher`,
deleting the `PendingGitLabPublisher` in the process.
| reify | python | pypi/warehouse | warehouse/oidc/models/gitlab.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/gitlab.py | Apache-2.0 |
def reify(self, session):
"""
Returns a `GooglePublisher` for this `PendingGooglePublisher`,
deleting the `PendingGooglePublisher` in the process.
"""
maybe_publisher = (
session.query(GooglePublisher)
.filter(
GooglePublisher.email == sel... |
Returns a `GooglePublisher` for this `PendingGooglePublisher`,
deleting the `PendingGooglePublisher` in the process.
| reify | python | pypi/warehouse | warehouse/oidc/models/google.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/google.py | Apache-2.0 |
def check_claim_binary(binary_func: Callable[[C, C], bool]) -> CheckClaimCallable[C]:
"""
Wraps a binary comparison function so that it takes three arguments instead,
ignoring the third.
This is used solely to make claim verification compatible with "trivial"
comparison checks like `str.__eq__`.
... |
Wraps a binary comparison function so that it takes three arguments instead,
ignoring the third.
This is used solely to make claim verification compatible with "trivial"
comparison checks like `str.__eq__`.
| check_claim_binary | python | pypi/warehouse | warehouse/oidc/models/_core.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/_core.py | Apache-2.0 |
def check_claim_invariant(value: C) -> CheckClaimCallable[C]:
"""
Wraps a fixed value comparison into a three-argument function.
This is used solely to make claim verification compatible with "invariant"
comparison checks, like "claim x is always the literal `true` value".
"""
def wrapper(
... |
Wraps a fixed value comparison into a three-argument function.
This is used solely to make claim verification compatible with "invariant"
comparison checks, like "claim x is always the literal `true` value".
| check_claim_invariant | python | pypi/warehouse | warehouse/oidc/models/_core.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/_core.py | Apache-2.0 |
def check_existing_jti(
_ground_truth,
signed_claim,
_all_signed_claims,
**kwargs: Unpack[CheckNamedArguments],
) -> bool:
"""Returns True if the checks passes or raises an exception."""
publisher_service: OIDCPublisherService = kwargs["publisher_service"]
if publisher_service.jwt_identifi... | Returns True if the checks passes or raises an exception. | check_existing_jti | python | pypi/warehouse | warehouse/oidc/models/_core.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/_core.py | Apache-2.0 |
def all_known_claims(cls) -> set[str]:
"""
Returns all claims "known" to this publisher.
"""
return (
cls.__required_verifiable_claims__.keys()
| cls.__required_unverifiable_claims__
| cls.__optional_verifiable_claims__.keys()
| cls.__preve... |
Returns all claims "known" to this publisher.
| all_known_claims | python | pypi/warehouse | warehouse/oidc/models/_core.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/_core.py | Apache-2.0 |
def check_claims_existence(cls, signed_claims: SignedClaims) -> None:
"""
Raises an error if any of the required claims for a Publisher is missing from
`signed_claims`.
This is used to check if required claims are missing from the token. If so,
an error is logged since this is l... |
Raises an error if any of the required claims for a Publisher is missing from
`signed_claims`.
This is used to check if required claims are missing from the token. If so,
an error is logged since this is likely a bug from the OIDC provider that
generated the token. Unexpected c... | check_claims_existence | python | pypi/warehouse | warehouse/oidc/models/_core.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/_core.py | Apache-2.0 |
def verify_claims(
self, signed_claims: SignedClaims, publisher_service: OIDCPublisherService
):
"""
Given a JWT that has been successfully decoded (checked for a valid
signature and basic claims), verify it against the more specific
claims of this publisher.
"""
... |
Given a JWT that has been successfully decoded (checked for a valid
signature and basic claims), verify it against the more specific
claims of this publisher.
| verify_claims | python | pypi/warehouse | warehouse/oidc/models/_core.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/_core.py | Apache-2.0 |
def publisher_url(
self, claims: SignedClaims | None = None
) -> str | None: # pragma: no cover
"""
NOTE: This is **NOT** a `@property` because we pass `claims` to it.
When calling, make sure to use `publisher_url()`
"""
# Only concrete subclasses are constructed.
... |
NOTE: This is **NOT** a `@property` because we pass `claims` to it.
When calling, make sure to use `publisher_url()`
| publisher_url | python | pypi/warehouse | warehouse/oidc/models/_core.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/_core.py | Apache-2.0 |
def stored_claims(
self, claims: SignedClaims | None = None
) -> dict: # pragma: no cover
"""
These are claims that are serialized into any macaroon generated for
this publisher. You likely want to use this to surface claims that
are not configured on the publishers, that mi... |
These are claims that are serialized into any macaroon generated for
this publisher. You likely want to use this to surface claims that
are not configured on the publishers, that might vary from one publish
event to the next, and are useful to show to the user.
NOTE: This is **... | stored_claims | python | pypi/warehouse | warehouse/oidc/models/_core.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/_core.py | Apache-2.0 |
def verify_url(self, url: str) -> bool:
"""
Verify a given URL against this Trusted Publisher's base URL
A URL is considered "verified" iff it matches the Trusted Publisher URL
such that, when both URLs are normalized:
- The scheme component is the same (e.g: both use `https`)
... |
Verify a given URL against this Trusted Publisher's base URL
A URL is considered "verified" iff it matches the Trusted Publisher URL
such that, when both URLs are normalized:
- The scheme component is the same (e.g: both use `https`)
- The authority component is the same (e.g.:... | verify_url | python | pypi/warehouse | warehouse/oidc/models/_core.py | https://github.com/pypi/warehouse/blob/master/warehouse/oidc/models/_core.py | Apache-2.0 |
def get_organization(organization_id):
"""
Return the organization object that represents the given organizationid, or None if
there is no organization for that ID.
""" |
Return the organization object that represents the given organizationid, or None if
there is no organization for that ID.
| get_organization | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_by_name(name):
"""
Return the organization object corresponding with the given organization name, or None
if there is no organization with that name.
""" |
Return the organization object corresponding with the given organization name, or None
if there is no organization with that name.
| get_organization_by_name | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_application(organization_application_id):
"""
Return the organization application object that represents the given
organization_application_id, or None if there is no organization application
for that ID.
""" |
Return the organization application object that represents the given
organization_application_id, or None if there is no organization application
for that ID.
| get_organization_application | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_applications_by_name(name):
"""
Return any organization application object that represents the given name
""" |
Return any organization application object that represents the given name
| get_organization_applications_by_name | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def find_organizationid(name):
"""
Find the unique organization identifier for the given name or None if there
is no organization with the given name.
""" |
Find the unique organization identifier for the given name or None if there
is no organization with the given name.
| find_organizationid | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organizations():
"""
Return a list of all organization objects, or None if there are none.
""" |
Return a list of all organization objects, or None if there are none.
| get_organizations | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organizations_by_user(user_id):
"""
Return a list of all organization objects associated with a given user id.
""" |
Return a list of all organization objects associated with a given user id.
| get_organizations_by_user | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def approve_organization_application(organization_application_id, request):
"""
Performs operations necessary to approve an organization
""" |
Performs operations necessary to approve an organization
| approve_organization_application | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def decline_organization_application(organization_application_id, request):
"""
Performs operations necessary to reject approval of an organization
""" |
Performs operations necessary to reject approval of an organization
| decline_organization_application | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def add_organization_application(
name,
display_name,
orgtype,
link_url,
description,
usage,
membership_size,
submitted_by,
):
"""
Accepts a organization object, and attempts to create an organization with those
attributes.
... |
Accepts a organization object, and attempts to create an organization with those
attributes.
| add_organization_application | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def add_catalog_entry(organization_id):
"""
Adds the organization name to the organization name catalog
""" |
Adds the organization name to the organization name catalog
| add_catalog_entry | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_role(organization_role_id):
"""
Return the org role object that represents the given org role id,
or None if there is no organization role for that ID.
""" |
Return the org role object that represents the given org role id,
or None if there is no organization role for that ID.
| get_organization_role | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_role_by_user(organization_id, user_id):
"""
Gets an organization role for a specified org and user
""" |
Gets an organization role for a specified org and user
| get_organization_role_by_user | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_roles(organization_id):
"""
Gets a list of organization roles for a specified org
""" |
Gets a list of organization roles for a specified org
| get_organization_roles | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def add_organization_role(organization_id, user_id, role_name):
"""
Adds an organization role for the specified org and user
""" |
Adds an organization role for the specified org and user
| add_organization_role | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def delete_organization_role(organization_role_id):
"""
Delete an organization role for a specified organization role id
""" |
Delete an organization role for a specified organization role id
| delete_organization_role | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_invite(organization_invite_id):
"""
Return the org invite object that represents the given org invite id,
or None if there is no organization invite for that ID.
""" |
Return the org invite object that represents the given org invite id,
or None if there is no organization invite for that ID.
| get_organization_invite | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_invite_by_user(organization_id, user_id):
"""
Gets an organization invite for a specified org and user
""" |
Gets an organization invite for a specified org and user
| get_organization_invite_by_user | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_invites(organization_id):
"""
Gets a list of organization invites for a specified org
""" |
Gets a list of organization invites for a specified org
| get_organization_invites | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_invites_by_user(user_id):
"""
Gets a list of organization invites for a specified user
""" |
Gets a list of organization invites for a specified user
| get_organization_invites_by_user | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def add_organization_invite(organization_id, user_id, invite_token):
"""
Adds an organization invitation for the specified user and org
""" |
Adds an organization invitation for the specified user and org
| add_organization_invite | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def delete_organization_invite(organization_invite_id):
"""
Delete an organization invite for the specified org invite id
""" |
Delete an organization invite for the specified org invite id
| delete_organization_invite | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def delete_organization(organization_id):
"""
Delete an organization for the specified organization id
""" |
Delete an organization for the specified organization id
| delete_organization | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def rename_organization(organization_id, name):
"""
Performs operations necessary to rename an Organization
""" |
Performs operations necessary to rename an Organization
| rename_organization | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def update_organization(organization_id, **changes):
"""
Accepts a organization object and attempts to update an organization with those
attributes
""" |
Accepts a organization object and attempts to update an organization with those
attributes
| update_organization | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_project(organization_id, project_id):
"""
Return the organization project object that represents the given
organization and project or None
""" |
Return the organization project object that represents the given
organization and project or None
| get_organization_project | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def add_organization_project(organization_id, project_id):
"""
Adds an association between the specified organization and project
""" |
Adds an association between the specified organization and project
| add_organization_project | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def delete_organization_project(organization_id, project_id):
"""
Removes an association between the specified organization and project
""" |
Removes an association between the specified organization and project
| delete_organization_project | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def record_tos_engagement(
organization_id,
revision,
engagement,
):
"""
Add a record of end user agreeing to terms of service,
or being notified of a terms of service change.
""" |
Add a record of end user agreeing to terms of service,
or being notified of a terms of service change.
| record_tos_engagement | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_subscription(organization_id, subscription_id):
"""
Return the organization subscription object that represents the given
organization subscription id or None
""" |
Return the organization subscription object that represents the given
organization subscription id or None
| get_organization_subscription | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def add_organization_subscription(organization_id, subscription_id):
"""
Adds an association between the specified organization and subscription
""" |
Adds an association between the specified organization and subscription
| add_organization_subscription | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def delete_organization_subscription(organization_id, subscription_id):
"""
Delete association between specified organization and subscription
""" |
Delete association between specified organization and subscription
| delete_organization_subscription | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_organization_stripe_customer(organization_id):
"""
Return the organization stripe customer object that is
associated to the given organization id or None
""" |
Return the organization stripe customer object that is
associated to the given organization id or None
| get_organization_stripe_customer | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def add_organization_stripe_customer(organization_id, stripe_customer_id):
"""
Adds an association between the specified organization and customer
""" |
Adds an association between the specified organization and customer
| add_organization_stripe_customer | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_teams_by_organization(organization_id):
"""
Return a list of all team objects for the specified organization,
or None if there are none.
""" |
Return a list of all team objects for the specified organization,
or None if there are none.
| get_teams_by_organization | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_team(team_id):
"""
Return a team object for the specified identifier,
""" |
Return a team object for the specified identifier,
| get_team | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def find_teamid(organization_id, team_name):
"""
Find the unique team identifier for the given organization and
team name or None if there is no such team.
""" |
Find the unique team identifier for the given organization and
team name or None if there is no such team.
| find_teamid | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def get_teams_by_user(user_id):
"""
Return a list of all team objects associated with a given user id.
""" |
Return a list of all team objects associated with a given user id.
| get_teams_by_user | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def add_team(organization_id, name):
"""
Attempts to create a team with the specified name in an organization
""" |
Attempts to create a team with the specified name in an organization
| add_team | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def rename_team(team_id, name):
"""
Performs operations necessary to rename a Team
""" |
Performs operations necessary to rename a Team
| rename_team | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
def delete_team(team_id):
"""
Delete team for the specified team id and all associated objects
""" |
Delete team for the specified team id and all associated objects
| delete_team | python | pypi/warehouse | warehouse/organizations/interfaces.py | https://github.com/pypi/warehouse/blob/master/warehouse/organizations/interfaces.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.