Skip to main content

repo_custom_patterns

Creates, updates, deletes, gets or lists a repo_custom_patterns resource.

Overview

Namerepo_custom_patterns
TypeResource
Idgithub.secret_scanning.repo_custom_patterns

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
idintegerThe ID of the custom pattern.
namestringThe name of the custom pattern.
created_atstring (date-time)The date and time the custom pattern was created in ISO 8601 format.
custom_pattern_versionstringThe version of the entity. This is used to confirm you're updating the current version of the entity and mitigate unintentionally overriding someone else's update.
end_delimiterstringThe end delimiter regex for the custom pattern.
must_matcharrayList of regexes that the secret must match.
must_not_matcharrayList of regexes that the secret must not match.
patternstringThe regular expression of the custom pattern.
push_protection_enabledbooleanWhether push protection is enabled for this custom pattern.
slugstringA URL-friendly identifier for the custom pattern, derived from its name.
start_delimiterstringThe start delimiter regex for the custom pattern.
statestringThe state of the custom pattern. (published, unpublished)
updated_atstring (date-time)The date and time the custom pattern was last updated in ISO 8601 format.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_repo_custom_patternsselectowner, repostate, push_protection, sort, direction, page, per_pageLists secret scanning custom patterns for a repository.

OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.
bulk_create_repo_custom_patternsinsertowner, repo, patternsBulk creates secret scanning custom patterns for a repository.

OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.
update_repo_custom_patternupdateowner, repo, pattern_id, custom_pattern_version, pattern, start_delimiter, end_delimiter, must_match, must_not_matchUpdates a secret scanning custom pattern for a repository.

OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.
bulk_delete_repo_custom_patternsdeleteowner, repoBulk deletes secret scanning custom patterns for a repository.

OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
ownerstringThe account owner of the repository. The name is not case sensitive.
pattern_idintegerThe ID of the custom pattern.
repostringThe name of the repository without the .git extension. The name is not case sensitive.
directionstringThe direction to sort the results by.
pageintegerThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pageintegerThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
push_protectionstringFilter custom patterns by whether push protection is enabled. When absent, returns patterns regardless of push protection status.
sortstringThe property to sort the results by.
statestringFilter custom patterns by state. When absent, returns patterns in all states.

SELECT examples

Lists secret scanning custom patterns for a repository.

OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.

SELECT
id,
name,
created_at,
custom_pattern_version,
end_delimiter,
must_match,
must_not_match,
pattern,
push_protection_enabled,
slug,
start_delimiter,
state,
updated_at
FROM github.secret_scanning.repo_custom_patterns
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND state = '{{ state }}'
AND push_protection = '{{ push_protection }}'
AND sort = '{{ sort }}'
AND direction = '{{ direction }}'
AND page = '{{ page }}'
AND per_page = '{{ per_page }}'
;

INSERT examples

Bulk creates secret scanning custom patterns for a repository.

OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.

INSERT INTO github.secret_scanning.repo_custom_patterns (
patterns,
owner,
repo
)
SELECT
'{{ patterns }}' /* required */,
'{{ owner }}',
'{{ repo }}'
RETURNING
created_patterns
;

UPDATE examples

Updates a secret scanning custom pattern for a repository.

OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.

UPDATE github.secret_scanning.repo_custom_patterns
SET
pattern = '{{ pattern }}',
start_delimiter = '{{ start_delimiter }}',
end_delimiter = '{{ end_delimiter }}',
must_match = '{{ must_match }}',
must_not_match = '{{ must_not_match }}',
custom_pattern_version = '{{ custom_pattern_version }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND pattern_id = '{{ pattern_id }}' --required
AND custom_pattern_version = '{{ custom_pattern_version }}' --required
AND pattern = '{{ pattern }}' --required
AND start_delimiter = '{{ start_delimiter }}' --required
AND end_delimiter = '{{ end_delimiter }}' --required
AND must_match = '{{ must_match }}' --required
AND must_not_match = '{{ must_not_match }}' --required
RETURNING
id,
name,
created_at,
custom_pattern_version,
end_delimiter,
must_match,
must_not_match,
pattern,
push_protection_enabled,
slug,
start_delimiter,
state,
updated_at;

DELETE examples

Bulk deletes secret scanning custom patterns for a repository.

OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.

DELETE FROM github.secret_scanning.repo_custom_patterns
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
;