drone-plugins / drone-matrix

Drone plugin for sending Matrix notifications
http://plugins.drone.io/drone-plugins/drone-matrix
Apache License 2.0
8 stars 4 forks source link

Docker Container prints entire environment #1

Closed jacksgt closed 6 years ago

jacksgt commented 6 years ago

Hi there,

thanks for writing this awesome plugin, just what I needed!

I just tried out your plugin with the following .drone.yml:

  notify-matrix:
    image: ptman/drone-plugin-matrix
    homeserver: https://matrix.org
    secrets:
      - source: matrix_userid
        target: plugin_userid
      - source: matrix_accesstoken
        target: plugin_accesstoken
      - source: matrix_roomid
        target: plugin_roomid
    when:
      status: [ success, changed, failure ]

I set the secrets appropriately in Drone and the notification was sent out. However, I had to discover that container prints its entire environment when running (the pipeline step executes successfully):

2017/11/19 17:31:54 main.go:13: []string{"DRONE_BRANCH=master", "DRONE_COMMIT_AUTHOR_AVATAR=https://git.example.com/avatars/2ec530ddfb33a0866f7e9867a5827497", "DRONE_JOB_FINISHED=1511112709", "CI_PREV_COMMIT_AUTHOR_NAME=jh", "CI=drone", "DRONE_COMMIT_AUTHOR=jh", "CI_BUILD_NUMBER=10", "DRONE_REPO_LINK=https://git.example.com/jh/drone-debug", "CI_BUILD_STARTED=1511112703", "CI_PREV_COMMIT_AUTHOR_AVATAR=https://git.example.com/avatars/2ec530ddfb33a0866f7e9867a5827497", "HOSTNAME=c5d1394e6ff0", "SHLVL=1", "DRONE_PREV_BUILD_NUMBER=9", "CI_WORKSPACE=/opt/build", "CI_SYSTEM_LINK=https://drone.cubieserver.de", "CI_BUILD_LINK=https://git.example.com/jh/drone-debug/compare/4defd60ecef11be7b448fdaecfacb2502a9ee0c0...e3b25d615efc28c598c6ce3ef44969798101615d", "PLUGIN_ACCESSTOKEN=REDACTED", "HOME=/root", "DRONE_COMMIT_BRANCH=master", "DRONE_REPO_SCM=git", "CI_PREV_COMMIT_AUTHOR=jh", "DRONE_BUILD_STATUS=success", "CI_PREV_COMMIT_BRANCH=master", "CI_JOB_STARTED=1511112703", "CI_BUILD_EVENT=push", "CI_JOB_NUMBER=1", "CI_BUILD_CREATED=1511112626", "CI_COMMIT_SHA=e3b25d615efc28c598c6ce3ef44969798101615d", "CI_REPO_NAME=jh/drone-debug", "CI_COMMIT_AUTHOR_EMAIL=jackdev@mailbox.org", "DRONE_ARCH=linux/amd64", "CI_COMMIT_REF=refs/heads/master", "DRONE_PREV_COMMIT_SHA=4defd60ecef11be7b448fdaecfacb2502a9ee0c0", "CI_PREV_BUILD_STATUS=success", "DRONE_COMMIT_MESSAGE=Add matrix notification\n", "CI_BUILD_FINISHED=1511112709", "DRONE_REMOTE_URL=https://git.example.com/jh/drone-debug.git", "DRONE_JOB_STATUS=success", "CI_REPO=jh/drone-debug", "CI_COMMIT_AUTHOR_NAME=jh", "DRONE_REPO_OWNER=jh", "CI_PREV_COMMIT_MESSAGE=explicitly set email from address\n", "CI_COMMIT_AUTHOR_AVATAR=https://git.example.com/avatars/2ec530ddfb33a0866f7e9867a5827497", "DRONE=true", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "DRONE_BUILD_STARTED=1511112703", "DRONE_BUILD_NUMBER=10", "DRONE_BUILD_LINK=https://drone.cubieserver.de/jh/drone-debug/10", "CI_JOB_FINISHED=1511112709", "DRONE_WORKSPACE=/opt/build", "CI_COMMIT_AUTHOR=jh", "CI_REPO_LINK=https://git.example.com/jh/drone-debug", "CI_PREV_BUILD_STARTED=1511100354", "CI_PREV_BUILD_NUMBER=9", "CI_COMMIT_BRANCH=master", "CI_PREV_BUILD_LINK=https://git.example.com/jh/drone-debug/compare/33aac637de50a08b9f41aeb9f44ea4a19389951e...4defd60ecef11be7b448fdaecfacb2502a9ee0c0", "DRONE_COMMIT=e3b25d615efc28c598c6ce3ef44969798101615d", "CI_REPO_REMOTE=https://git.example.com/jh/drone-debug.git", "CI_SYSTEM_ARCH=linux/amd64", "DRONE_JOB_STARTED=1511112703", "DRONE_JOB_NUMBER=1", "DRONE_BUILD_EVENT=push", "DRONE_BUILD_CREATED=1511112626", "DRONE_COMMIT_AUTHOR_EMAIL=jackdev@mailbox.org", "DRONE_COMMIT_SHA=e3b25d615efc28c598c6ce3ef44969798101615d", "DRONE_REPO_NAME=drone-debug", "CI_BUILD_STATUS=success", "CI_SYSTEM_NAME=drone", "DRONE_COMMIT_REF=refs/heads/master", "DRONE_MACHINE=082775a308d3", "PLUGIN_HOMESERVER=https://matrix.org", "DRONE_PREV_BUILD_STATUS=success", "PWD=/opt/build", "CI_PREV_BUILD_EVENT=push", "CI_PREV_COMMIT_AUTHOR_EMAIL=jackdev@mailbox.org", "PLUGIN_ROOMID=REDACTED", "DRONE_COMMIT_LINK=https://git.example.com/jh/drone-debug/compare/4defd60ecef11be7b448fdaecfacb2502a9ee0c0...e3b25d615efc28c598c6ce3ef44969798101615d", "CI_PREV_BUILD_CREATED=1511100354", "CI_PREV_COMMIT_SHA=4defd60ecef11be7b448fdaecfacb2502a9ee0c0", "DRONE_BUILD_FINISHED=1511112709", "CI_PREV_COMMIT_REF=refs/heads/master", "PLUGIN_USERID=REDACTED", "CI_COMMIT_MESSAGE=Add matrix notification\n", "DRONE_REPO=jh/drone-debug", "CI_SYSTEM=drone", "CI_PREV_BUILD_FINISHED=1511100362", "CI_JOB_STATUS=success", "CI_REMOTE_URL=https://git.example.com/jh/drone-debug.git"}

PLUGIN_ACCESSTOKEN, PLUGIN_ROOMID and PLUGIN_USERID are exposed, which is of course not the idea behind secrets.

ptman commented 6 years ago

Hi, and thank you for reporting the problem. This is slightly embarrasing. I removed that environment printing line, but I didn't rebuild the docker image afterwards. So while there is no such line in the code in this repo, an earlier build had it. Now I have updated the docker image. Is it any better?

jacksgt commented 6 years ago

Haha, I was wondering wether someone forgot a print statement in there, but looking at the code I couldn't find any :-)

You should really look into Automating the Docker Image build by Docker Hub. This can be easily done with my modified Dockerfile at https://github.com/ptman/drone-plugin-matrix/pull/2. Then in Docker Hub, click on "Create" and "Create Automated Build" in the top-right corner, choose "Github" as the source and select your repository. After creating the automated build, you should then go to "Build Settings" and "link" to the golang repository. This will automatically trigger rebuilds of your image when the golang image is updated (e.g. with security fixes).