Skip to content

Instantly share code, notes, and snippets.

@DanBurkhardt
Created October 10, 2019 08:44
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save DanBurkhardt/06fa67678fbf167c5158cd5ec781032b to your computer and use it in GitHub Desktop.
Xcode Server Web UI - Disable 'Integrate' button for all users on bots web page

Xcode Server - Disable "Integrate" button access for /Xcode web page

License: MIT

disclaimer

this is for experiemntal use only do not use this if you don't know what you're doing you could do something bad or irreversible, idk, read the script first and see if it looks alright to run

Problem: When you visit {xcodeserver}.com/xcode there is this terrible little button there named "integrate". Xcode Server doesn't have any web UI configuration options whatsoever. None, literally nothing. This is a huge issue if you want to want to grant "view-only" access to someone who is not a developer.

Major pain points:

  • You can't disable integration triggering by user or role
  • You can't / shouldnt give access to this page to someone who isn't a developer to go triggering builds all over the place

Solution: Just completely disable the "integrate" button on the webUI. Developers can trigger builds from Xcode, there is literally no need to have unmitigated access like this from the WebUI. Keep this script handy for the future (in case it gets overridden by, say, a new version of Xcode, which will definitely happen)

  1. back it up
  • make sure to backup the default file and put it somewhere safe
  • cp /Applications/Xcode.app/Contents/Developer/usr/share/xcs/xcswebui/webui/javascripts/webui-optimized.js $somewheresafe
  1. download these files
  • cd to wherever you put them
  1. make another working copy of the default file
  • cp $path-to-file/webui-optimized.js .
  1. on your working copy, edit the button out of the js
  • open the file in your editor of choice
  • cmd + f to search and look for: "_XCS.BotDetail.BotList.Integrate": "Integrate"
  • modify by removing the "Integrate" and replacing with " " // this empty space is important
  • it should now read: "_XCS.BotDetail.BotList.Integrate": " "
  • save your working copy
  1. run this script
  • open terminal
  • run sudo disableIntegrateButton.sh

Wrap-up As long as you are sudo, it should work. Then:

  • navigate to {xcodeserver}.com/xcode and login
  • the "integrate" button should be vanquished

If you don't see it, you may have a cached version of the page. Open a new private browser window and try again.

License

Copyright 2019 GigabiteLabs, & Giganom, LLC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#!/bin/bash
# This script modifies the default JS for XCS
# to disable access to the "integrate"
# button seen on the bots page.
# source your paths
source ./webUI_vars.sh
# js file with integrate button disabled
replacementJS="$DISABLE_INTEGRATE_BUTTON_REPLACEMENT_JS_PATH/webui-optimized.js"
# make a backup, just in case
echo "backing up default js file"
if [ ! -d "~/.xcs_webUI_backup" ]; then
echo "default js file was already backed up"
else
# only make a new dir and backup if it hasn't been done before
mkdir ~/.xcs_webUI_backup; cp $JS_file ~/.xcs_webUI_backup; echo "default file backed up to ~/.xcs_webUI_backup"
fi
# start
echo "\nDisabling integrate button on /xcode bots page UI"
echo "removing default js file"
# check that the file exists
if [ -f "$JS_FILE" ]; then
rm $JS_FILE
else
echo "the file appears to be missing, sure hope you backed it up! \n\njk you can find it in ~/.xcs_webUI_backup\n"
fi
# test before removal
if [ ! -f "$JS_FILE" ]; then
echo "default js file is now gone"
else
echo "removal of default js file failed, try logging in as sudo user"
exit;
fi
echo "copying new js with button disabled"
cp $replacementJS $JS_DIR
# test for replacement
if [ -f "$JS_FILE" ]; then
echo "replacement succeeded\nthe integrate button is now disabled"
else
echo "replacement of the default js file failed, try logging in as sudo user"
fi
#!/bin/bash
# the script will source this file, be sure to replace with the path
export DISABLE_INTEGRATE_BUTTON_REPLACEMENT_JS_PATH="$(echo replace me with PATH TO NEW JS; exit)"
## default xc server paths, don't change these
# directory to replace js file
export JS_Dir="/Applications/Xcode.app/Contents/Developer/usr/share/xcs/xcswebui/webui/javascripts/"
# path to default js file
export JS_FILE="/Applications/Xcode.app/Contents/Developer/usr/share/xcs/xcswebui/webui/javascripts/webui-optimized.js"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment