-
Notifications
You must be signed in to change notification settings - Fork 0
Initial setup
The goal of OmitFiles is to replace private keys or passwords in configuration files prior to committing them to a git repo. There is of course some setup for this, starting with creating the filter JSON. For detailed information on how the file is structured and what each element does use this wiki page.
The first thing you need to do is set up your git repo, do not commit anything until you have configured and setup OmitFiles. Any files that are committed with your passwords or tokens will be in the repo forever and are very hard to remove after the fact. You can read on how to create a local git repo here, and you can see how to upload the local repo to GitHub here. I would recommend starting your repo off as private to ensure that you have all of your tokens filtered before sharing it. Make sure you ignore the filter file before making any commits!
Now that you have your git repo setup we need to get all of the tokens that need to be filtered together. Each token that needs to be removed needs its own JSON object. The JSON file is made up of 3 elements per object, the file path, the filter, and the token/key. When you set up the filter you need all 3 of those values in each JSON object. An example filter should look like this.
[{
"file": "plugins/DiscordSRV/config.yml",
"filter": "%token%",
"key": "oHrRpWTzSbVgMJvLDNGhoHrRpWTzSbVgMJvLDNGhoHrRpWTzSbVgMJvLDNGh"
},
{
"file": "plugins/DiscordSRV/config.yml",
"filter": "%password%",
"key": "oHrRpWTzSbVgMJvLDNGhoHrRpWTzSbVgMJvLDNGhoHrRpWTzSbVgMJvLDNGh"
},
{
"file": "plugins/DiscordSRV/config.yml",
"filter": "Experiment_JdbcUsername: \"%Username%\"",
"key": "Experiment_JdbcUsername: \"ServerName\""
}
]
The file should be a JSON file and should be accessible by the user that runs the OmitFiles jar. Make sure you ignore the filter file before making any commits!
Make sure you ignore the filter file before making any commits! With the JSON filter setup you are ready to run the jar. There are two arguments that must be passed to the jar when run. They do not have any default values and OmmitFiles will not run if they are invalid or missing. The first argument should be the relative path to the filter you made in the last setup and the second argument is the mode in which you want to run Omit files. You can either run OmitFiles in hide or show mode.
Hide takes your key value and replaces it with the specified filter value, ensuring that the private token/password is out of the file and replaced with a safe value. Show essentially does the opposite, replacing your token with the associated key and allowing the server or program to start with the needed values.
An example start command would be as follows:
java -jar /home/OmitFiles-1.0.jar SurvivalOmit.json hide
That start command would use the SurvivalOmit.json file that is in the same directory as the OmitFiles jar to hide all of the specified keys and replace them with the associated filter.
To show the keys using the same filter JSON you can use this command:
java -jar /home/OmitFiles-1.0.jar SurvivalOmit.json show
This is just like the first command except it will run the filter in reverse and show all of your private keys so that your program/server can run as normal.