File tree Expand file tree Collapse file tree 5 files changed +43
-21
lines changed
queueConsumer/src/actions/services Expand file tree Collapse file tree 5 files changed +43
-21
lines changed Original file line number Diff line number Diff line change @@ -41,5 +41,6 @@ GOOGLE_ARTIFACT_UPLOADER_KEY_FILE=anymal-grand-tour-3b7a5d0c8ef4.json
4141# can be left empty if you don't want to use docker hub
4242DOCKER_HUB_USERNAME =
4343DOCKER_HUB_PASSWORD =
44+ VITE_DOCKER_HUB_NAMESPACE =
4445
4546ARTIFACTS_UPLOADER_IMAGE = rslethz/grandtour-datasets:artifact-uploader-latest
Original file line number Diff line number Diff line change @@ -100,11 +100,16 @@ export class ActionService {
100100 data : CreateTemplateDto ,
101101 auth : AuthHeader ,
102102 ) : Promise < ActionTemplateDto > {
103- //if (!data.dockerImage.startsWith('rslethz/')) {
104- // throw new ConflictException(
105- // 'Only images from the rslethz namespace are allowed',
106- // );
107- //}
103+ const dockerhub_namespace = process . env [ 'VITE_DOCKER_HUB_NAMESPACE' ] ;
104+ // assert that we only run images from a specified namespace
105+ if (
106+ dockerhub_namespace !== undefined &&
107+ ! data . dockerImage . startsWith ( dockerhub_namespace )
108+ ) {
109+ throw new ConflictException (
110+ `Only images from the ${ dockerhub_namespace } namespace are allowed` ,
111+ ) ;
112+ }
108113 const exists = await this . actionTemplateRepository . exists ( {
109114 where : {
110115 name : data . name ,
Original file line number Diff line number Diff line change @@ -190,4 +190,12 @@ export default {
190190 get VITE_USE_FAKE_OAUTH_FOR_DEVELOPMENT ( ) : boolean {
191191 return asBoolean ( process . env [ 'VITE_USE_FAKE_OAUTH_FOR_DEVELOPMENT' ] ) ;
192192 } ,
193+
194+ /**
195+ * @returns Docker Hub namespace for image validation (optional)
196+ * @example rslethz/
197+ */
198+ get DOCKER_HUB_NAMESPACE ( ) : string {
199+ return process . env [ 'VITE_DOCKER_HUB_NAMESPACE' ] ?? '' ;
200+ } ,
193201} ;
Original file line number Diff line number Diff line change @@ -515,16 +515,20 @@ async function submitAnalysis() {
515515 });
516516 return ;
517517 }
518- // if (!editingTemplate.value.imageName.startsWith('rslethz/')) {
519- // Notify.create({
520- // group: false,
521- // message: 'The image name must start with "rslethz/"',
522- // color: 'negative',
523- // position: 'bottom',
524- // timeout: 2000,
525- // });
526- // return;
527- // }
518+ const dockerhubNamespace = import .meta .env .VITE_DOCKER_HUB_NAMESPACE ;
519+ if (
520+ dockerhubNamespace &&
521+ ! editingTemplate .value .imageName .startsWith (` ${dockerhubNamespace } ` )
522+ ) {
523+ Notify .create ({
524+ group: false ,
525+ message: ` The image name must start with "${dockerhubNamespace }/" ` ,
526+ color: ' negative' ,
527+ position: ' bottom' ,
528+ timeout: 2000 ,
529+ });
530+ return ;
531+ }
528532
529533 // post: the input should be valid now
530534 let template = editingTemplate .value ;
Original file line number Diff line number Diff line change @@ -303,12 +303,16 @@ export class DockerDaemon {
303303
304304 @tracing ( )
305305 private async getImage ( dockerImage : string ) {
306- // assert that we only run rslethz images
307- //if (!dockerImage.startsWith('rslethz/')) {
308- // throw new Error(
309- // 'Only images from the rslethz organization are allowed',
310- // );
311- //}
306+ const dockerhub_namespace = process . env [ 'VITE_DOCKER_HUB_NAMESPACE' ] ;
307+ // assert that we only run images from a specified namespace
308+ if (
309+ dockerhub_namespace !== undefined &&
310+ ! dockerImage . startsWith ( dockerhub_namespace )
311+ ) {
312+ throw new Error (
313+ `Only images from the ${ dockerhub_namespace } namespace are allowed` ,
314+ ) ;
315+ }
312316
313317 // check if docker socket is available
314318 if ( ! this . docker || ! ( await this . docker . ping ( ) ) ) {
You can’t perform that action at this time.
0 commit comments