mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
Allow to set custom trusted clone plugins (#4352)
Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Thomas Anderson <127358482+zc-devs@users.noreply.github.com> Co-authored-by: Anbraten <6918444+anbraten@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -104,8 +104,8 @@
|
||||
"desc": "Permit 'deployment' runs for successful pipelines. All users with with push permissions can trigger these, so use with caution."
|
||||
},
|
||||
"netrc_only_trusted": {
|
||||
"netrc_only_trusted": "Only inject git credentials into trusted clone plugins",
|
||||
"desc": "When enabled, git credentials are accessible only to trusted clone plugins specified in WOODPECKER_PLUGINS_TRUSTED_CLONE. Otherwise, custom clone plugins can use git credentials. This setting has no affect on non-clone steps."
|
||||
"netrc_only_trusted": "Custom trusted clone plugins",
|
||||
"desc": "Plugins listed here will get access to netrc credentials that can be used to clone repositories from the forge or push to it."
|
||||
},
|
||||
"trusted": {
|
||||
"trusted": "Trusted",
|
||||
|
||||
@@ -76,7 +76,7 @@ export interface Repo {
|
||||
// Events that will cancel running pipelines before starting a new one
|
||||
cancel_previous_pipeline_events: string[];
|
||||
|
||||
netrc_only_trusted: boolean;
|
||||
netrc_trusted: string[];
|
||||
}
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
@@ -104,7 +104,7 @@ export type RepoSettings = Pick<
|
||||
| 'allow_pr'
|
||||
| 'allow_deploy'
|
||||
| 'cancel_previous_pipeline_events'
|
||||
| 'netrc_only_trusted'
|
||||
| 'netrc_trusted'
|
||||
>;
|
||||
|
||||
export interface RepoPermissions {
|
||||
|
||||
@@ -15,11 +15,25 @@
|
||||
:label="$t('repo.settings.general.allow_deploy.allow')"
|
||||
:description="$t('repo.settings.general.allow_deploy.desc')"
|
||||
/>
|
||||
<Checkbox
|
||||
v-model="repoSettings.netrc_only_trusted"
|
||||
:label="$t('repo.settings.general.netrc_only_trusted.netrc_only_trusted')"
|
||||
:description="$t('repo.settings.general.netrc_only_trusted.desc')"
|
||||
/>
|
||||
</InputField>
|
||||
|
||||
<InputField
|
||||
v-slot="{ id }"
|
||||
:label="$t('repo.settings.general.netrc_only_trusted.netrc_only_trusted')"
|
||||
docs-url="docs/usage/project-settings#custom-trusted-clone-plugins"
|
||||
>
|
||||
<span class="ml-1 mb-2 text-wp-text-alt-100">{{ $t('repo.settings.general.netrc_only_trusted.desc') }}</span>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<div v-for="image in repoSettings.netrc_trusted" :key="image" class="flex gap-2">
|
||||
<TextField :id="id" :model-value="image" disabled />
|
||||
<Button type="button" color="gray" start-icon="trash" @click="removeImage(image)" />
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<TextField :id="id" v-model="newImage" @keydown.enter.prevent="addNewImage" />
|
||||
<Button type="button" color="gray" start-icon="plus" @click="addNewImage" />
|
||||
</div>
|
||||
</div>
|
||||
</InputField>
|
||||
|
||||
<InputField
|
||||
@@ -178,7 +192,7 @@ function loadRepoSettings() {
|
||||
allow_pr: repo.value.allow_pr,
|
||||
allow_deploy: repo.value.allow_deploy,
|
||||
cancel_previous_pipeline_events: repo.value.cancel_previous_pipeline_events || [],
|
||||
netrc_only_trusted: repo.value.netrc_only_trusted,
|
||||
netrc_trusted: repo.value.netrc_trusted || [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -236,4 +250,20 @@ const cancelPreviousPipelineEventsOptions: CheckboxOption[] = [
|
||||
},
|
||||
{ value: WebhookEvents.Deploy, text: i18n.t('repo.pipeline.event.deploy') },
|
||||
];
|
||||
|
||||
const newImage = ref('');
|
||||
function addNewImage() {
|
||||
if (!newImage.value) {
|
||||
return;
|
||||
}
|
||||
repoSettings.value?.netrc_trusted.push(newImage.value);
|
||||
newImage.value = '';
|
||||
}
|
||||
function removeImage(image: string) {
|
||||
if (!repoSettings.value) {
|
||||
throw new Error('Unexpected: repoSettings should be set');
|
||||
}
|
||||
|
||||
repoSettings.value.netrc_trusted = repoSettings.value.netrc_trusted.filter((i) => i !== image);
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user