1- # Jit Customer Scripts
1+ # Jit Customer Scripts README
22
3- [ ![ codecov] ( https://codecov.io/gh/jitsecurity/jit-customer-scripts/graph/badge.svg?token=76IhFwTPjv )] ( https://codecov.io/gh/jitsecurity/jit-customer-scripts )
3+ The README provided is an extensive guide on how to use the ` jit-customer-scripts ` project. \
4+ The Makefile described is composed of commands that ease the installation, configuration, and running of the scripts
5+ within the project.
46
5- This project provides customer scripts to help them with their JIT solution. \
6- The ` create-teams.py ` script's goal is to create teams and update assets based on the provided JSON file.
7+ ## Prerequisites
8+
9+ - Python 3.x
10+ - Git
11+ - make
12+
13+ To make sure you have all you can run this command:
14+
15+ ### Centos distro
16+
17+ ``` shell
18+ sudo yum install -y git make && git clone https://github.com/jitsecurity/jit-customer-scripts.git && cd jit-customer-scripts
19+ ```
20+
21+ ### Ubuntu distro
22+
23+ ``` shell
24+ sudo apt update && sudo apt install -y git make && git clone https://github.com/jitsecurity/jit-customer-scripts.git && cd jit-customer-scripts
25+ ```
26+
27+ ### Mac
28+
29+ ``` shell
30+ brew install git make && git clone https://github.com/jitsecurity/jit-customer-scripts.git && cd jit-customer-scripts
31+ ```
32+
33+ Here's a breakdown of the provided README and Makefile:
34+
35+ ## Supported Scripts
36+
37+ The Makefile consists of several commands to facilitate the installation, configuration, and running of scripts. Here's
38+ a link to the docs for each one:
39+
40+ * [ syncing jit teams] ( src/scripts/sync_teams/sync-teams.md )
41+ * [ self-hosted-runners] ( src/scripts/self-hosted-runners/self-hosted-runner.md )
42+
43+ ## Hierarchical Structure of the Commands:
44+
45+ 1 . ** sync-teams**
46+ - install
47+ - configure
48+ - run
49+
50+ 2 . ** self-hosted-runner**
51+ - centos
52+ - ubuntu
753
854## Project Structure
955
@@ -13,9 +59,11 @@ The project has the following structure:
1359jit-customer-scripts/
1460├── src/
1561│ └── scripts/
16- │ └── create_teams.py
62+ │ └── sync_teams
63+ │ └── sync_teams.py
1764| └── self-hosted-runners
18- │ └── setup-self-hosted-runner-centos.sh
65+ │ └── setup-rootless-docker-centos.sh
66+ │ └── setup-rootless-docker-ubuntu.sh
1967│ └── ...
2068├── src/
2169│ └── utils/
@@ -34,26 +82,6 @@ jit-customer-scripts/
3482- ` Makefile ` : Provides commands to help with project setup and execution.
3583- ` README.md ` : This file.
3684
37- ## Prerequisites
38-
39- - Python 3.x
40- - Git
41- - make
42-
43- To make sure you have all you can run this command:
44-
45- #### Centos
46-
47- ``` shell
48- sudo yum install -y git make && git clone https://github.com/jitsecurity/jit-customer-scripts.git && cd jit-customer-scripts
49- ```
50-
51- #### Ubuntu
52-
53- ``` shell
54- sudo apt install -y git make && git clone https://github.com/jitsecurity/jit-customer-scripts.git && cd jit-customer-scripts
55- ```
56-
5785## Generating API Keys
5886
5987* To generate Github Personal Access Token(PAT) refer to
@@ -63,148 +91,15 @@ sudo apt install -y git make && git clone https://github.com/jitsecurity/jit-cus
6391
6492> We recommend generating a fine-grained PAT with read-only access to the organization for the use of this script.
6593
66- ## Installation
67-
68- 1 . Clone the repository:
69-
70- ``` shell
71- git clone --branch 1.0.0 git@github.com:jitsecurity/jit-customer-scripts.git
72- ```
73-
74- 2 . Change into the project directory:
75-
76- ``` shell
77- cd jit-customer-scripts
78- ```
79-
80- 3 . Create a virtual environment and install the required dependencies:
81-
82- ``` shell
83- make install
84- ```
85-
86- ## Configuration
87-
88- Before running the script, you need to configure the necessary environment variables. Follow these steps:
89-
90- 1 . Run the configuration command:
91-
92- ``` shell
93- make configure
94- ```
95-
96- 2 . Enter the required information when prompted:
97- - GitHub organization name
98- - API client ID
99- - API client secret
100- - GitHub token
101-
102- 3 . The command will generate a ` .env ` file with the provided information.
103-
104- ## Usage
105-
106- ### Creating Teams from Github Topics
107-
108- To run the script and create teams and update assets, use the following command:
109-
110- ``` shell
111- make create-teams
112- ```
113-
114- This command is a convenience utility that extracts the teams to generate from Github topics. \
115- It runs these commands:
116-
117- ``` bash
118- python src/utils/github_topics_to_json_file.py
119- python src/scripts/create_teams.py teams.json
120- ```
121-
122- This command will fetch the repository names and topics from the GitHub API and generate the JSON file. And then it will
123- create the teams and update the assets.
124-
125- > We recommend using something like Github Actions and Github secrets to run this script on a schedule to make sure you
126- > are always synced.
127-
128- #### Using External JSON File
129-
130- You can also provide a JSON file containing team details using a command line argument directly. The JSON file should
131- have the following structure:
132-
133- ``` json
134- {
135- "teams" : [
136- {
137- "name" : " Team 1" ,
138- "members" : [
139- " user1" ,
140- " user2"
141- ],
142- "resources" : [
143- {
144- "type" : " {resource_type}" ,
145- "name" : " Resource 1"
146- },
147- {
148- "type" : " {resource_type}" ,
149- "name" : " Resource 2"
150- }
151- ]
152- },
153- {
154- "name" : " Team 2" ,
155- "members" : [
156- " user3" ,
157- " user4"
158- ],
159- "resources" : [
160- {
161- "type" : " {resource_type}" ,
162- "name" : " Resource 3"
163- }
164- ]
165- }
166- ]
167- }
168- ```
169-
170- You can run the command like this:
171-
172- ``` shell
173- python scripts/create_teams.py path/to/teams.json
174- ```
175-
176- Replace ` path/to/teams.json ` with the actual path to your JSON file.
177-
178- #### Excluding Topics
179-
180- You can exclude certain topics from being considered when creating teams. \
181- To exclude topics, you could add them in the ` make configure ` command or update this env var in
182- the ` .env ` file: ` TEAM_WILDCARD_TO_EXCLUDE ` .
183-
184- For example, to exclude topics that contain the word "test", you can set the variable as follows:
185-
186- TEAM_WILDCARD_TO_EXCLUDE=*test*
187-
188- This will exclude topics with names like "test", "test123", and "abc-testing".
189-
190- #### Development
94+ ## Development
19195
19296To override Jit's API endpoint, you can set the ` JIT_API_ENDPOINT ` environment variable. If the variable is not set, the
19397default value will be used.
19498
195- ### Settings Up Self-Hosted Runners
196-
197- To setup self-hosted runners, use the following command:
99+ ## Help
198100
199- You need to take the self hosted runners token from the Github Actions page of your repository.
200- ` https://github.com/<your-github-org-name>/jit/settings/actions/runners `
201-
202- #### Running on CentOS
101+ To see the available commands and their descriptions, use the following command:
203102
204103``` shell
205- make setup-self-hosted-runner-centos token= < your-token > github_organization= < your-github-org-name >
104+ make help
206105```
207-
208- You will be prompted to answer some questions about your runner. \
209- When you complete this step, restart your EC2 machine. \
210- The runner will be automatically started on boot.
0 commit comments