Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(security): Fix redis start issue from #2863 #3115

Conversation

jim-wang-intel
Copy link
Contributor

@jim-wang-intel jim-wang-intel commented Feb 3, 2021

Now redis starts with conf file with credentials and thus insecure gap is removed

  • Refactor security-bootstrap-redis to be absorbed into security-bootstrapper as one of commands
  • Remove security-bootstrap-redis binary build
  • Redis db server starts with config file with credentials
  • Update snaps

Closes: #2863

Signed-off-by: Jim Wang yutsung.jim.wang@intel.com

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x ] Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-go/blob/master/.github/Contributing.md.

What is the current behavior?

Redis server starts insecurely as it is not started in authenticated mode.

Issue Number: #2863

What is the new behavior?

Now Redis server starts with credentials in conf file and thus it is started securely.

Does this PR introduce a breaking change?

  • Yes
  • [x ] No

New Imports

  • Yes
  • [x ] No

Specific Instructions

Are there any specific instructions or things that should be known prior to reviewing?
Local docker test file:

networks:
  edgex-network:
    driver: bridge
services:
  app-service-rules:
    container_name: edgex-app-service-configurable-rules
    depends_on:
    - consul
    - data
    environment:
      BINDING_PUBLISHTOPIC: events
      CLIENTS_COMMAND_HOST: edgex-core-command
      CLIENTS_COREDATA_HOST: edgex-core-data
      CLIENTS_DATA_HOST: edgex-core-data
      CLIENTS_METADATA_HOST: edgex-core-metadata
      CLIENTS_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_RULESENGINE_HOST: edgex-kuiper
      CLIENTS_SCHEDULER_HOST: edgex-support-scheduler
      CLIENTS_VIRTUALDEVICE_HOST: edgex-device-virtual
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_PROFILE: rules-engine
      EDGEX_SECURITY_SECRET_STORE: "false"
      MESSAGEBUS_SUBSCRIBEHOST_HOST: edgex-core-data
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-app-service-configurable-rules
      SERVICE_PORT: 48100
    hostname: edgex-app-service-configurable-rules
    image: nexus3.edgexfoundry.org:10004/docker-app-service-configurable:master
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:48100:48100/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
  command:
    command: /core-command -cp=consul.http://edgex-core-consul:8500 --registry --confdir=/res
    container_name: edgex-core-command
    depends_on:
    - consul
    - database
    - metadata
    - secretstore-setup
    - security-bootstrapper
    entrypoint:
    - /edgex-init/ready_to_run_wait_install.sh
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      CLIENTS_COMMAND_HOST: edgex-core-command
      CLIENTS_COREDATA_HOST: edgex-core-data
      CLIENTS_DATA_HOST: edgex-core-data
      CLIENTS_METADATA_HOST: edgex-core-metadata
      CLIENTS_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_RULESENGINE_HOST: edgex-kuiper
      CLIENTS_SCHEDULER_HOST: edgex-support-scheduler
      CLIENTS_VIRTUALDEVICE_HOST: edgex-device-virtual
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "true"
      PROXY_SETUP_HOST: edgex-proxy-setup
      REGISTRY_HOST: edgex-core-consul
      SECRETSTORE_HOST: edgex-vault
      SECRETSTORE_PORT: '8200'
      SECRETSTORE_TOKENFILE: /tmp/edgex/secrets/edgex-core-command/secrets-token.json
      SERVICE_HOST: edgex-core-command
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: edgex-core-command
    image: edgexfoundry/docker-core-command-go:0.0.0-dev
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:48082:48082/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
    volumes:
    - edgex-init:/edgex-init:ro,z
    - /tmp/edgex/secrets/edgex-core-command:/tmp/edgex/secrets/edgex-core-command:ro,z
  consul:
    container_name: edgex-core-consul
    depends_on:
    - security-bootstrapper
    - vault
    entrypoint:
    - /edgex-init/consul_wait_install.sh
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      EDGEX_SECURITY_SECRET_STORE: "true"
      PROXY_SETUP_HOST: edgex-proxy-setup
      SECRETSTORE_HOST: edgex-vault
      SECRETSTORE_PORT: '8200'
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: edgex-core-consul
    image: consul:1.9.1
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:8500:8500/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    volumes:
    - consul-config:/consul/config:z
    - consul-data:/consul/data:z
    - edgex-init:/edgex-init:ro,z
    - /tmp/edgex/secrets/edgex-consul:/tmp/edgex/secrets/edgex-consul:ro,z
    - /tmp/edgex/secrets/edgex-kong:/tmp/edgex/secrets/edgex-kong:ro,z
  data:
    command: /core-data -cp=consul.http://edgex-core-consul:8500 --registry --confdir=/res
    container_name: edgex-core-data
    depends_on:
    - consul
    - database
    - metadata
    - secretstore-setup
    - security-bootstrapper
    entrypoint:
    - /edgex-init/ready_to_run_wait_install.sh
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      CLIENTS_COMMAND_HOST: edgex-core-command
      CLIENTS_COREDATA_HOST: edgex-core-data
      CLIENTS_DATA_HOST: edgex-core-data
      CLIENTS_METADATA_HOST: edgex-core-metadata
      CLIENTS_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_RULESENGINE_HOST: edgex-kuiper
      CLIENTS_SCHEDULER_HOST: edgex-support-scheduler
      CLIENTS_VIRTUALDEVICE_HOST: edgex-device-virtual
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "true"
      PROXY_SETUP_HOST: edgex-proxy-setup
      REGISTRY_HOST: edgex-core-consul
      SECRETSTORE_HOST: edgex-vault
      SECRETSTORE_PORT: '8200'
      SECRETSTORE_TOKENFILE: /tmp/edgex/secrets/edgex-core-data/secrets-token.json
      SERVICE_HOST: edgex-core-data
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: edgex-core-data
    image: edgexfoundry/docker-core-data-go:0.0.0-dev
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:5563:5563/tcp
    - 127.0.0.1:48080:48080/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
    volumes:
    - edgex-init:/edgex-init:ro,z
    - /tmp/edgex/secrets/edgex-core-data:/tmp/edgex/secrets/edgex-core-data:ro,z
  database:
    container_name: edgex-redis
    depends_on:
    - secretstore-setup
    - security-bootstrapper
    entrypoint:
    - /edgex-init/redis_wait_install.sh
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      CLIENTS_COMMAND_HOST: edgex-core-command
      CLIENTS_COREDATA_HOST: edgex-core-data
      CLIENTS_DATA_HOST: edgex-core-data
      CLIENTS_METADATA_HOST: edgex-core-metadata
      CLIENTS_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_RULESENGINE_HOST: edgex-kuiper
      CLIENTS_SCHEDULER_HOST: edgex-support-scheduler
      CLIENTS_VIRTUALDEVICE_HOST: edgex-device-virtual
      DATABASECONFIG_NAME: redis.conf
      DATABASECONFIG_PATH: /run/redis/conf
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "true"
      PROXY_SETUP_HOST: edgex-proxy-setup
      REGISTRY_HOST: edgex-core-consul
      SECRETSTORE_HOST: edgex-vault
      SECRETSTORE_PORT: '8200'
      SECRETSTORE_TOKENFILE: /tmp/edgex/secrets/edgex-security-bootstrap-redis/secrets-token.json
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: edgex-redis
    image: redis:6.0.9-alpine
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:6379:6379/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    tmpfs:
    - /run
    volumes:
    - db-data:/data:z
    - edgex-init:/edgex-init:ro,z
    - redis-config:/run/redis/conf:z
    - /tmp/edgex/secrets/edgex-security-bootstrap-redis:/tmp/edgex/secrets/edgex-security-bootstrap-redis:ro,z
  kong:
    container_name: kong
    depends_on:
    - kong-db
    - security-bootstrapper
    entrypoint:
    - /edgex-init/kong_wait_install.sh
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      KONG_ADMIN_ACCESS_LOG: /dev/stdout
      KONG_ADMIN_ERROR_LOG: /dev/stderr
      KONG_ADMIN_LISTEN: 0.0.0.0:8001, 0.0.0.0:8444 ssl
      KONG_DATABASE: postgres
      KONG_PG_HOST: kong-db
      KONG_PG_PASSWORD_FILE: /tmp/postgres-config/.pgpassword
      KONG_PROXY_ACCESS_LOG: /dev/stdout
      KONG_PROXY_ERROR_LOG: /dev/stderr
      PROXY_SETUP_HOST: edgex-proxy-setup
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: kong
    image: kong:2.3-alpine
    networks:
      edgex-network: {}
    ports:
    - 8000:8000/tcp
    - 127.0.0.1:8001:8001/tcp
    - 8443:8443/tcp
    - 127.0.0.1:8444:8444/tcp
    read_only: true
    restart: on-failure
    security_opt:
    - no-new-privileges:true
    tmpfs:
    - /run
    - /tmp
    tty: true
    volumes:
    - edgex-init:/edgex-init:ro,z
    - postgres-config:/tmp/postgres-config:z
    - kong:/usr/local/kong:rw
  kong-db:
    container_name: kong-db
    depends_on:
    - security-bootstrapper
    entrypoint:
    - /edgex-init/postgres_wait_install.sh
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      EDGEX_SECURITY_SECRET_STORE: "true"
      POSTGRES_DB: kong
      POSTGRES_PASSWORD_FILE: /tmp/postgres-config/.pgpassword
      POSTGRES_USER: kong
      PROXY_SETUP_HOST: edgex-proxy-setup
      SECRETSTORE_HOST: edgex-vault
      SECRETSTORE_PORT: '8200'
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: kong-db
    image: postgres:12.3-alpine
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:5432:5432/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    tmpfs:
    - /var/run
    - /tmp
    - /run
    volumes:
    - edgex-init:/edgex-init:ro,z
    - postgres-config:/tmp/postgres-config:z
    - postgres-data:/var/lib/postgresql/data:z
  metadata:
    command: /core-metadata -cp=consul.http://edgex-core-consul:8500 --registry --confdir=/res
    container_name: edgex-core-metadata
    depends_on:
    - consul
    - database
    - notifications
    - secretstore-setup
    - security-bootstrapper
    entrypoint:
    - /edgex-init/ready_to_run_wait_install.sh
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      CLIENTS_COMMAND_HOST: edgex-core-command
      CLIENTS_COREDATA_HOST: edgex-core-data
      CLIENTS_DATA_HOST: edgex-core-data
      CLIENTS_METADATA_HOST: edgex-core-metadata
      CLIENTS_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_RULESENGINE_HOST: edgex-kuiper
      CLIENTS_SCHEDULER_HOST: edgex-support-scheduler
      CLIENTS_VIRTUALDEVICE_HOST: edgex-device-virtual
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "true"
      NOTIFICATIONS_SENDER: edgex-core-metadata
      PROXY_SETUP_HOST: edgex-proxy-setup
      REGISTRY_HOST: edgex-core-consul
      SECRETSTORE_HOST: edgex-vault
      SECRETSTORE_PORT: '8200'
      SECRETSTORE_TOKENFILE: /tmp/edgex/secrets/edgex-core-metadata/secrets-token.json
      SERVICE_HOST: edgex-core-metadata
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: edgex-core-metadata
    image: edgexfoundry/docker-core-metadata-go:0.0.0-dev
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:48081:48081/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
    volumes:
    - edgex-init:/edgex-init:ro,z
    - /tmp/edgex/secrets/edgex-core-metadata:/tmp/edgex/secrets/edgex-core-metadata:ro,z
  notifications:
    command: /support-notifications -cp=consul.http://edgex-core-consul:8500 --registry
      --confdir=/res
    container_name: edgex-support-notifications
    depends_on:
    - consul
    - database
    - secretstore-setup
    - security-bootstrapper
    entrypoint:
    - /edgex-init/ready_to_run_wait_install.sh
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      CLIENTS_COMMAND_HOST: edgex-core-command
      CLIENTS_COREDATA_HOST: edgex-core-data
      CLIENTS_DATA_HOST: edgex-core-data
      CLIENTS_METADATA_HOST: edgex-core-metadata
      CLIENTS_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_RULESENGINE_HOST: edgex-kuiper
      CLIENTS_SCHEDULER_HOST: edgex-support-scheduler
      CLIENTS_VIRTUALDEVICE_HOST: edgex-device-virtual
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "true"
      PROXY_SETUP_HOST: edgex-proxy-setup
      REGISTRY_HOST: edgex-core-consul
      SECRETSTORE_HOST: edgex-vault
      SECRETSTORE_PORT: '8200'
      SECRETSTORE_TOKENFILE: /tmp/edgex/secrets/edgex-support-notifications/secrets-token.json
      SERVICE_HOST: edgex-support-notifications
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: edgex-support-notifications
    image: edgexfoundry/docker-support-notifications-go:0.0.0-dev
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:48060:48060/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
    volumes:
    - edgex-init:/edgex-init:ro,z
    - /tmp/edgex/secrets/edgex-support-notifications:/tmp/edgex/secrets/edgex-support-notifications:ro,z
  proxy-setup:
    container_name: edgex-proxy-setup
    depends_on:
    - kong
    - secretstore-setup
    - security-bootstrapper
    entrypoint:
    - /edgex-init/proxy_setup_wait_install.sh
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      CLIENTS_COMMAND_HOST: edgex-core-command
      CLIENTS_COREDATA_HOST: edgex-core-data
      CLIENTS_DATA_HOST: edgex-core-data
      CLIENTS_METADATA_HOST: edgex-core-metadata
      CLIENTS_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_RULESENGINE_HOST: edgex-kuiper
      CLIENTS_SCHEDULER_HOST: edgex-support-scheduler
      CLIENTS_VIRTUALDEVICE_HOST: edgex-device-virtual
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "false"
      KONGURL_SERVER: kong
      PROXY_SETUP_HOST: edgex-proxy-setup
      REGISTRY_HOST: edgex-core-consul
      SECRETSERVICE_SERVER: edgex-vault
      SECRETSERVICE_TOKENPATH: /tmp/edgex/secrets/edgex-security-proxy-setup/secrets-token.json
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: edgex-proxy-setup
    image: edgexfoundry/docker-security-proxy-setup-go:0.0.0-dev
    networks:
      edgex-network: {}
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
    volumes:
    - edgex-init:/edgex-init:ro,z
    - /tmp/edgex/secrets/edgex-security-proxy-setup:/tmp/edgex/secrets/edgex-security-proxy-setup:ro,z
  rulesengine:
    container_name: edgex-kuiper
    depends_on:
    - app-service-rules
    environment:
      EDGEX__DEFAULT__PORT: 5566
      EDGEX__DEFAULT__PROTOCOL: tcp
      EDGEX__DEFAULT__SERVER: edgex-app-service-configurable-rules
      EDGEX__DEFAULT__SERVICESERVER: http://edgex-core-data:48080
      EDGEX__DEFAULT__TOPIC: events
      KUIPER__BASIC__CONSOLELOG: "true"
      KUIPER__BASIC__RESTPORT: 48075
    hostname: edgex-kuiper
    image: emqx/kuiper:1.1.1-alpine
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:20498:20498/tcp
    - 127.0.0.1:48075:48075/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    volumes:
    - kuiper-data:/kuiper/data:z
  scheduler:
    command: /support-scheduler -cp=consul.http://edgex-core-consul:8500 --registry
      --confdir=/res
    container_name: edgex-support-scheduler
    depends_on:
    - consul
    - database
    - secretstore-setup
    - security-bootstrapper
    entrypoint:
    - /edgex-init/ready_to_run_wait_install.sh
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      CLIENTS_COMMAND_HOST: edgex-core-command
      CLIENTS_COREDATA_HOST: edgex-core-data
      CLIENTS_DATA_HOST: edgex-core-data
      CLIENTS_METADATA_HOST: edgex-core-metadata
      CLIENTS_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_RULESENGINE_HOST: edgex-kuiper
      CLIENTS_SCHEDULER_HOST: edgex-support-scheduler
      CLIENTS_VIRTUALDEVICE_HOST: edgex-device-virtual
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "true"
      INTERVALACTIONS_SCRUBAGED_HOST: edgex-core-data
      INTERVALACTIONS_SCRUBPUSHED_HOST: edgex-core-data
      PROXY_SETUP_HOST: edgex-proxy-setup
      REGISTRY_HOST: edgex-core-consul
      SECRETSTORE_HOST: edgex-vault
      SECRETSTORE_PORT: '8200'
      SECRETSTORE_TOKENFILE: /tmp/edgex/secrets/edgex-support-scheduler/secrets-token.json
      SERVICE_HOST: edgex-support-scheduler
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: edgex-support-scheduler
    image: edgexfoundry/docker-support-scheduler-go:0.0.0-dev
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:48085:48085/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
    volumes:
    - edgex-init:/edgex-init:ro,z
    - /tmp/edgex/secrets/edgex-support-scheduler:/tmp/edgex/secrets/edgex-support-scheduler:ro,z
  secretstore-setup:
    container_name: edgex-secretstore-setup
    depends_on:
    - security-bootstrapper
    - vault
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      EDGEX_GROUP: '2001'
      EDGEX_USER: '2002'
      PROXY_SETUP_HOST: edgex-proxy-setup
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: edgex-secretstore-setup
    image: edgexfoundry/docker-security-secretstore-setup-go:0.0.0-dev
    networks:
      edgex-network: {}
    read_only: true
    security_opt:
    - no-new-privileges:true
    tmpfs:
    - /run
    - /vault
    volumes:
    - edgex-init:/edgex-init:ro,z
    - /tmp/edgex/secrets:/tmp/edgex/secrets:z
    - vault-config:/vault/config:z
  security-bootstrapper:
    container_name: edgex-security-bootstrapper
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      EDGEX_GROUP: '2001'
      EDGEX_USER: '2002'
      PROXY_SETUP_HOST: edgex-proxy-setup
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
    hostname: edgex-security-bootstrapper
    image: edgexfoundry/docker-security-bootstrapper-go:0.0.0-dev
    networks:
      edgex-network: {}
    read_only: true
    security_opt:
    - no-new-privileges:true
    volumes:
    - edgex-init:/edgex-init:z
  system:
    container_name: edgex-sys-mgmt-agent
    depends_on:
    - command
    - consul
    - data
    - metadata
    - notifications
    - scheduler
    environment:
      CLIENTS_COMMAND_HOST: edgex-core-command
      CLIENTS_COREDATA_HOST: edgex-core-data
      CLIENTS_DATA_HOST: edgex-core-data
      CLIENTS_METADATA_HOST: edgex-core-metadata
      CLIENTS_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_RULESENGINE_HOST: edgex-kuiper
      CLIENTS_SCHEDULER_HOST: edgex-support-scheduler
      CLIENTS_VIRTUALDEVICE_HOST: edgex-device-virtual
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "false"
      EXECUTORPATH: /sys-mgmt-executor
      METRICSMECHANISM: executor
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-sys-mgmt-agent
    hostname: edgex-sys-mgmt-agent
    image: edgexfoundry/docker-sys-mgmt-agent-go:0.0.0-dev
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:48090:48090/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock:z
  vault:
    cap_add:
    - IPC_LOCK
    command: server
    container_name: edgex-vault
    depends_on:
    - security-bootstrapper
    entrypoint:
    - /edgex-init/vault_wait_install.sh
    environment:
      API_GATEWAY_HOST: kong
      API_GATEWAY_STATUS_PORT: '8001'
      PROXY_SETUP_HOST: edgex-proxy-setup
      STAGEGATE_BOOTSTRAPPER_HOST: edgex-security-bootstrapper
      STAGEGATE_BOOTSTRAPPER_STARTPORT: '54321'
      STAGEGATE_DATABASE_HOST: edgex-redis
      STAGEGATE_DATABASE_PORT: '6379'
      STAGEGATE_DATABASE_READYPORT: '6379'
      STAGEGATE_KONGDB_HOST: kong-db
      STAGEGATE_KONGDB_PORT: '5432'
      STAGEGATE_KONGDB_READYPORT: '54325'
      STAGEGATE_READY_TORUNPORT: '54329'
      STAGEGATE_REGISTRY_HOST: edgex-core-consul
      STAGEGATE_REGISTRY_PORT: '8500'
      STAGEGATE_REGISTRY_READYPORT: '54324'
      STAGEGATE_SECRETSTORESETUP_HOST: edgex-secretstore-setup
      STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT: '54322'
      STAGEGATE_WAITFOR_TIMEOUT: 60s
      VAULT_ADDR: http://edgex-vault:8200
      VAULT_CONFIG_DIR: /vault/config
      VAULT_UI: "true"
    hostname: edgex-vault
    image: vault:1.5.3
    networks:
      edgex-network: {}
    ports:
    - 127.0.0.1:8200:8200/tcp
    tmpfs:
    - /vault/config
    volumes:
    - edgex-init:/edgex-init:ro,z
    - vault-file:/vault/file:z
    - vault-logs:/vault/logs:z
version: '3.7'
volumes:
  consul-config: {}
  consul-data: {}
  db-data: {}
  edgex-init: {}
  kong: {}
  kuiper-data: {}
  postgres-config: {}
  postgres-data: {}
  redis-config: {}
  vault-config: {}
  vault-file: {}
  vault-logs: {}

Other information

TBD: need to update patch file for SNAP @tonyespy

@jim-wang-intel jim-wang-intel added enhancement New feature or request snap Snap packaging security-services 2-medium priority denoting issues with cross-cutting project impact ireland labels Feb 3, 2021
@jim-wang-intel jim-wang-intel added this to the Ireland milestone Feb 3, 2021
@jim-wang-intel jim-wang-intel self-assigned this Feb 3, 2021
@jim-wang-intel jim-wang-intel changed the title feat(security): Fix redis start issue #2863 feat(security): Fix redis start issue from #2863 Feb 3, 2021
@jim-wang-intel
Copy link
Contributor Author

Hi @tonyespy would you please help to generate a new updated PATCH file for the related snapcraft.yml changes? Thanks!

Comment on lines 183 to 187
# This is a simple service which calls into vault to retrieve the Redis password and then
# generate Redis config file for Redis to start up with credentials and ACL rules.
# Redis should be start once the doneFile is created. Once the config file has been generated and
# verified authenticated connection, this service exits. In the Docker version,
# the customized redis' entrypoint.sh performs the similar actions as described above.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it not be more efficient for the snap to create a wrapper script for launching redis rather than creating a separate service?

Copy link
Collaborator

@bnevis-i bnevis-i Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For that matter, the snap install could write the config file and the redis sevice could just start redis directly pointing at it... on second thought... the database password is created during secretstore-setup, which I think is dynamic, so that won't work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the key or major purpose of that bootstrap-redis is to "dynamically" generate the config file as the credentials are generated from secretstore-setup during the run time for the first time. Hence, you can NOT just do the snap install.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tonyespy Maybe a command-chain would be useful here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jim is just converting an existing oneshot service in the snap which used to call security-bootstrap-redis. The redis service is already defined to start after this service, so this transition to using bootstrap doesn't really impact the service ordering.

Yes, we could re-implement this via command-chain, however I don't see any added benefit to doing so, unless I'm missing something?

bnevis-i
bnevis-i previously approved these changes Feb 3, 2021
lenny-goodell
lenny-goodell previously approved these changes Feb 3, 2021
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lenny-goodell
Copy link
Member

recheck


/* Redis ACL configuration
*
* The followings are contents excerpted from redis 6.0 conf documentation:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to have a pointer to the upstream documentation as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

# The ACL rules that describe what a user can do are the following:
#
# on Enable the user: it is possible to authenticate as this user.
# off Disable the user: it's no longer possible to authenticate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might also be nice to just include the bits of configuration that we're using (i.e. we only use "on").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

# is a glob-style pattern like the one of KEYS.
# It is possible to specify multiple patterns.
# allkeys Alias for ~*
# resetkeys Flush the list of allowed keys patterns.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment, the conf file we create doesn't use allcommand, nocommands, ~<pattern>, allkeys, or resetkeys.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

# "nopass" status. After "resetpass" the user has no associated
# passwords and there is no way to authenticate without adding
# some password (or setting it as "nopass" later).
# reset Performs the following actions: resetpass, resetkeys, off,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, we don't use reset, resetpass, nopass, or <<password>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

#
# Now DEBUG was removed when alice had yet no commands in the set of allowed
# commands, later all the commands are added, so the user will be able to
# execute everything.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, maybe just explain the doc which applies to our conf (e.g. +@ALL -@dangerous)? Maybe even include our conf scheme and explain it?

user default on allkeys +@all -@dangerous > password
requirepass password

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

Comment on lines 183 to 187
# This is a simple service which calls into vault to retrieve the Redis password and then
# generate Redis config file for Redis to start up with credentials and ACL rules.
# Redis should be start once the doneFile is created. Once the config file has been generated and
# verified authenticated connection, this service exits. In the Docker version,
# the customized redis' entrypoint.sh performs the similar actions as described above.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jim is just converting an existing oneshot service in the snap which used to call security-bootstrap-redis. The redis service is already defined to start after this service, so this transition to using bootstrap doesn't really impact the service ordering.

Yes, we could re-implement this via command-chain, however I don't see any added benefit to doing so, unless I'm missing something?

bnevis-i
bnevis-i previously approved these changes Feb 8, 2021
Now redis starts with conf file with credentials and thus insecure gap is removed

- Refactor security-bootstrap-redis to absorbed into security-bootstrapper as one of command
- Remove security-bootstrap-redis binary build
- Redis db server starts with config file with credentials
- Update snaps

Closes: edgexfoundry#2863

Signed-off-by: Jim Wang <yutsung.jim.wang@intel.com>
Address Bryon's PR feedback

Signed-off-by: Jim Wang <yutsung.jim.wang@intel.com>
Address Lenny's PR feedback about unit tests

Signed-off-by: Jim Wang <yutsung.jim.wang@intel.com>
Change the redis.conf file permission to 0600
Make chown for redis' conf to redis:redis 999:1000 as part of redis' uid and gid creation
Add doc's url and detailed explanation for redis' conf EdgeX is currently using

Signed-off-by: Jim Wang <yutsung.jim.wang@intel.com>
lenny-goodell
lenny-goodell previously approved these changes Feb 8, 2021
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@andresrinivasan andresrinivasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrt the implementation, this looks good. Kudos for switching over to ACLs. One of the conversations I had with the V2 API team was to consider that with ACLs and deterministic key names, we could segregate microservice access to only the keys they should have access to. If that does evolve, this will need a little rework. Another thing to note is that by removing the dangerous commands, the commands useful for debugging Redis apps have also been removed. I had tried to document tips to debug with security enabled in the various security .md files and I suggest pointing out enabling the dangerous commands while debugging may be useful.

Circling back to #2863, while using a config file conforms to the ADR and addresses the risk of Redis being unsecured on boot, I wonder if we're trading a timing risk for a clear password on disk risk. Another way #2863 could be addressed is starting Redis unsecured and pointing to an empty RDB file, dynamically setting the password/ACLs, then pointing back to the actual RDB file.

@jim-wang-intel
Copy link
Contributor Author

Wrt the implementation, this looks good. Kudos for switching over to ACLs. One of the conversations I had with the V2 API team was to consider that with ACLs and deterministic key names, we could segregate microservice access to only the keys they should have access to. If that does evolve, this will need a little rework. Another thing to note is that by removing the dangerous commands, the commands useful for debugging Redis apps have also been removed. I had tried to document tips to debug with security enabled in the various security .md files and I suggest pointing out enabling the dangerous commands while debugging may be useful.

Thanks @andresrinivasan. A good thought about the debugging redis app. It is truly that you might lose the ability to run the dangerous command like INFO server directly from redis server; however, I think developer can always achieve that by swap out the current conf file with their own redis config file for that matter. There is ENVs provided you can always override the redis.conf file should it find you for that purpose.

Circling back to #2863, while using a config file conforms to the ADR and addresses the risk of Redis being unsecured on boot, I wonder if we're trading a timing risk for a clear password on disk risk. Another way #2863 could be addressed is starting Redis unsecured and pointing to an empty RDB file, dynamically setting the password/ACLs, then pointing back to the actual RDB file.

From file system mounting point of view, as long as you can mount it on the temp. file system like docker's tmfs, in which it also runs in memory (see docker's doc https://docs.docker.com/storage/tmpfs/) , I think the password written out should be ok. At least it is not as bad as of it today and just like Redis' data in memory.

@bnevis-i
Copy link
Collaborator

bnevis-i commented Feb 8, 2021

Circling back to #2863, while using a config file conforms to the ADR and addresses the risk of Redis being unsecured on boot, I wonder if we're trading one timing risk for a clear password on disk risk. Another way #2863 could be addressed is starting Redis unsecured and pointing to an empty RDB file, dynamically setting the password/ACLs, then pointing back to the actual RDB file.

What is to stop someone, if they can get at the Redis password, from simply starting their own server to read the RDB files directly bypassing the provided Redis? The whole issue could be avoided if Redis simply persisted the ACL configuration.

@andresrinivasan
Copy link
Member

Wrt the implementation, this looks good. Kudos for switching over to ACLs. One of the conversations I had with the V2 API team was to consider that with ACLs and deterministic key names, we could segregate microservice access to only the keys they should have access to. If that does evolve, this will need a little rework. Another thing to note is that by removing the dangerous commands, the commands useful for debugging Redis apps have also been removed. I had tried to document tips to debug with security enabled in the various security .md files and I suggest pointing out enabling the dangerous commands while debugging may be useful.

Thanks @andresrinivasan. A good thought about the debugging redis app. It is truly that you might lose the ability to run the dangerous command like INFO server directly from redis server; however, I think developer can always achieve that by swap out the current conf file with their own redis config file for that matter. There is ENVs provided you can always override the redis.conf file should it find you for that purpose.

In addition to INFO, MONITOR, BGSAVE, and FLUSHDB are quite useful. I'm only suggesting we document this and document specifically how the developer overrides this. When I was trying to figure out how to integrate with Vault I consumed a lot of time from Bryon and Lenny because not enough was written down to help me figure out how to debug things.

@tonyespy
Copy link
Member

tonyespy commented Feb 8, 2021

@tonyespy

Jim is just converting an existing oneshot service in the snap which used to call security-bootstrap-redis. The redis service is > already defined to start after this service, so this transition to using bootstrap doesn't really impact the service ordering.
Yes, we could re-implement this via command-chain, however I don't see any added benefit to doing so, unless I'm missing something?

Is it better to have the service, a wrapper script, or a command chain? Personally I don't see the point of the service.

In the grand scheme of things, there's not much difference between a oneshot service, a wrapper script or a command chain. In this case, Jim just converted an existing one-shot service which already works "as is". Yes, he could certainly re-implement this as a redis wrapper script or command-chain executable, but as there's no real advantage to the other two approaches, I'm not sure I see your point?

@bnevis-i
Copy link
Collaborator

bnevis-i commented Feb 8, 2021

but as there's no real advantage to the other two approaches, I'm not sure I see your point?

Ok.

Remove the change ownership from golang code and only do the change ownership inside the docker's entrypoint script because
snap doesn't work with chow to a non-existing userId.

Signed-off-by: Jim Wang <yutsung.jim.wang@intel.com>
@jim-wang-intel
Copy link
Contributor Author

Wrt the implementation, this looks good. Kudos for switching over to ACLs. One of the conversations I had with the V2 API team was to consider that with ACLs and deterministic key names, we could segregate microservice access to only the keys they should have access to. If that does evolve, this will need a little rework. Another thing to note is that by removing the dangerous commands, the commands useful for debugging Redis apps have also been removed. I had tried to document tips to debug with security enabled in the various security .md files and I suggest pointing out enabling the dangerous commands while debugging may be useful.

Thanks @andresrinivasan. A good thought about the debugging redis app. It is truly that you might lose the ability to run the dangerous command like INFO server directly from redis server; however, I think developer can always achieve that by swap out the current conf file with their own redis config file for that matter. There is ENVs provided you can always override the redis.conf file should it find you for that purpose.

In addition to INFO, MONITOR, BGSAVE, and FLUSHDB are quite useful. I'm only suggesting we document this and document specifically how the developer overrides this. When I was trying to figure out how to integrate with Vault I consumed a lot of time from Bryon and Lenny because not enough was written down to help me figure out how to debug things.

@andresrinivasan I created a note md file for the aspect of developers to use their own configuration file: Developer-notes.md.

@tonyespy
Copy link
Member

tonyespy commented Feb 8, 2021

@jim-wang-intel here's the update for the snap patch...

0001-fix-snap-update-the-snap-optimization-patch.patch.txt

tonyespy
tonyespy previously approved these changes Feb 8, 2021
Copy link
Member

@tonyespy tonyespy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes, LGTM!

lenny-goodell
lenny-goodell previously approved these changes Feb 8, 2021
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

 patch -p1 < ./0001-fix-snap-update-the-snap-optimization-patch.patch.txt
patching file snap/local/patches/0001-optimize-build-for-pipeline-CI-check.patch

Signed-off-by: Jim Wang <yutsung.jim.wang@intel.com>
@sonarcloud
Copy link

sonarcloud bot commented Feb 8, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@tonyespy tonyespy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (again)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2-medium priority denoting issues with cross-cutting project impact enhancement New feature or request ireland security-services snap Snap packaging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redis always started in insecure mode
5 participants