3934ca77a63df9b77d22c9a4bb1c1401907c4818
[integration.git] / test / security / check_versions / README.md
1 # Kubernetes Binaries Versions Inspector
2
3 **Kubernetes Binaries Versions Inspector** (`k8s_bin_versions_inspector`) is a
4 python module for verifying versions of CPython and OpenJDK binaries installed
5 in the kubernetes cluster containers.
6
7 ## Commands
8
9 ### Creating environment
10
11 All development and testing process, should be done in prepared virtual machine,
12 that is containing development environment for this project. Vagrant plugins,
13 that are required to start virtual machine: `vagrant-libvirt`, `vagrant-reload`,
14 `vagrant-sshfs`.
15
16 ```bash
17 cd env
18 vagrant up
19 vagrant ssh
20 ```
21
22 ### Install dependencies
23
24 To install dependencies for normal usage of script, run this command.
25
26 ```bash
27 pip3 install -r env/requirements.txt
28 ```
29
30 ### Code formatting
31
32 ```bash
33 black src tests
34 ```
35
36 ### Code static analysis
37
38 ```bash
39 pylint -d C0330 src
40 ```
41
42 ### Automatic tests
43
44 To running the automated tests is required to have properly configured
45 kubernetes cluster, which is in the virtual machine, that is containing
46 development environment.
47
48 ```bash
49 PYTHONPATH=src pytest -vv -s tests
50 ```
51
52 ### Removing caches
53
54 ```bash
55 find -name __pycache__   -exec rm -Rf {} +
56 find -name .pytest_cache -exec rm -Rf {} +
57 ```
58
59 ## Acceptable format
60
61 Example of the acceptable file format:
62
63 ```yaml
64 python:
65     - 3.6.9
66     - 3.7.3
67 java:
68     - 11.0.7
69 ```
70
71 ## Paths research
72
73 Commands to research for the paths
74 of the software binaries in multiple docker images:
75
76 ```bash
77 docker run --entrypoint /bin/sh python:buster   -c "which python"
78 docker run --entrypoint /bin/sh python:alpine   -c "which python"
79 docker run --entrypoint /bin/sh python:slim     -c "which python"
80 docker run --entrypoint /bin/sh python:2-buster -c "which python"
81 docker run --entrypoint /bin/sh python:2-alpine -c "which python"
82 docker run --entrypoint /bin/sh python:2-slim   -c "which python"
83 docker run --entrypoint /bin/sh ubuntu:bionic   -c "apt-get update && apt-get install -y python  && which python"
84 docker run --entrypoint /bin/sh ubuntu:bionic   -c "apt-get update && apt-get install -y python3 && which python3"
85 docker run --entrypoint /bin/sh openjdk         -c "type java"
86 ```
87
88 ## Todo
89
90 List of features, that should be implemented:
91
92 - Complete license and copyrights variables.
93 - Find a way, to safe searching of the container files from Kubernetes API.
94 - Parallelization of executing binaries on the single container.
95 - Parallelization of versions determination in multiple containers.
96 - Support for determination the old versions of OpenJDK (attribute `-version`).
97 - Deleting namespace from cluster in development environment (for example,
98   during cluster reset), cause hanging in namespace terminating state.
99 - Find a nicer way to extracting exit code from execution result.
100
101 ## Links
102
103 - <https://github.com/kubernetes-client/python>
104 - <https://github.com/kubernetes-client/python/issues/812>
105 - <https://success.docker.com/article/kubernetes-namespace-stuck-in-terminating>