Skip to content

Commit 76a4685

Browse files
authored
Merge pull request #30 from LeChatP/develop
Full rust rewriting and new functionnalities
2 parents 0e5f702 + 952c901 commit 76a4685

File tree

180 files changed

+54949
-2026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+54949
-2026
lines changed

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[alias]
2+
xtask = "run --package xtask --"

.github/workflows/audit.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Audit
2+
3+
on:
4+
push:
5+
paths:
6+
- '**/Cargo.toml'
7+
- '**/Cargo.lock'
8+
schedule:
9+
- cron: '0 0 * * *'
10+
11+
jobs:
12+
13+
rust-quality-gate:
14+
name: Rust Quality Gate
15+
runs-on: ubuntu-latest
16+
permissions: write-all
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
21+
- name: Install Rust toolchain
22+
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
23+
with:
24+
profile: minimal
25+
toolchain: stable
26+
components: clippy
27+
override: true
28+
29+
- name: Cargo audit
30+
uses: actions-rs/audit-check@v1
31+
with:
32+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build.yml

Lines changed: 11 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,15 @@ on:
1010
jobs:
1111
build:
1212
runs-on: ubuntu-latest
13-
env:
14-
DOCKER: 1
1513
steps:
16-
- uses: actions/checkout@v2
17-
14+
- uses: actions/checkout@v3
1815
- name: Update version
1916
run: sudo apt-get update
2017
- name: Install Dependencies
21-
run: sudo ./configure.sh -yd
22-
- name: Configure PAM
2318
run: |
24-
sudo bash -c 'echo "#%PAM-1.0
25-
auth [success=1 default=ignore] pam_permit.so
26-
auth requisite pam_permit.so
27-
auth required pam_permit.so
28-
account [success=1 default=ignore] pam_permit.so
29-
account requisite pam_permit.so
30-
account required pam_permit.so
31-
session [success=1 default=ignore] pam_permit.so
32-
session requisite pam_permit.so
33-
session required pam_permit.so" | tee /etc/pam.d/sr'
34-
- name: Build Project
35-
run: sudo -E make -e install
36-
- name: Run Project
37-
run: sr -h
38-
- name: Print capabilities with sr
39-
run: sr cat /proc/self/status
40-
rust-build:
41-
runs-on: ubuntu-latest
42-
env:
43-
working-directory: "role-manager"
44-
steps:
45-
- uses: actions/checkout@v2
46-
- name: Install Rust
47-
uses: actions-rs/toolchain@v1
48-
with:
49-
toolchain: stable
50-
override: true
51-
- name: rustup update
52-
run: rustup update
53-
- name: cargo version
54-
run: cargo version
55-
- name: Update version
56-
run: sudo apt-get update
57-
- name: Install Dependencies
58-
run: sudo ./configure.sh -yd
19+
sudo ./configure.sh -yd
20+
sudo cp /root/.cargo/bin/bpf-linker /usr/bin/
21+
echo "/home/runner/.cargo/bin" >> $GITHUB_PATH
5922
- name: Configure PAM
6023
run: |
6124
sudo bash -c 'echo "#%PAM-1.0
@@ -68,24 +31,15 @@ jobs:
6831
session [success=1 default=ignore] pam_permit.so
6932
session requisite pam_permit.so
7033
session required pam_permit.so" | tee /etc/pam.d/sr'
71-
- name: Install sr tool
72-
run: sudo -E make -e install
73-
env:
74-
DEBUG: 1
7534
- name: Add read access on config on rootasrole... Because Github Actions...
7635
run: sudo chmod a+r /etc/security/rootasrole.xml
7736
- name: print config
78-
run: |
79-
sr cat /etc/security/rootasrole.xml
37+
run: cat /etc/security/rootasrole.xml
8038
- name: getenv
8139
run: env
82-
- name: sr getenv
83-
run: sr env
84-
- name: Print capabilities with sr
85-
run: sr cat /proc/self/status
86-
- name: Build Project
87-
run: cargo build --release
88-
working-directory: ${{ env.working-directory }}
89-
- name: Run Project
90-
run: cargo run --release -- -h
91-
working-directory: ${{ env.working-directory }}
40+
- name: Install Project
41+
run: sudo -E make -e install
42+
- name: Run Sr
43+
run: /usr/bin/sr -h
44+
- name: Run Chsr
45+
run: /usr/bin/chsr -h

.github/workflows/quality.yml

Lines changed: 15 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -21,116 +21,34 @@ on:
2121
branches:
2222
- 'main'
2323

24-
permissions:
25-
contents: read
26-
2724
jobs:
28-
codacy-security-scan:
29-
permissions:
30-
contents: read # for actions/checkout to fetch code
31-
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
32-
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
33-
name: Codacy Security Scan
34-
runs-on: ubuntu-latest
35-
steps:
36-
# Checkout the repository to the GitHub Actions runner
37-
- name: Checkout code
38-
uses: actions/checkout@v3
39-
40-
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
41-
- name: Run Codacy Analysis CLI
42-
uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b
43-
with:
44-
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
45-
# You can also omit the token and run the tools that support default configurations
46-
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
47-
verbose: true
48-
output: results.sarif
49-
format: sarif
50-
# Adjust severity of non-security issues
51-
gh-code-scanning-compat: true
52-
# Force 0 exit code to allow SARIF file generation
53-
# This will handover control about PR rejection to the GitHub side
54-
max-allowed-issues: 2147483647
5525

56-
# Upload the SARIF file generated in the previous step
57-
- name: Upload SARIF results file
58-
uses: github/codeql-action/upload-sarif@v2
59-
with:
60-
sarif_file: results.sarif
6126
rust-quality-gate:
6227
name: Rust Quality Gate
63-
env:
64-
working-directory: "role-manager"
6528
runs-on: ubuntu-latest
29+
permissions: write-all
6630
steps:
6731
- name: Checkout code
68-
uses: actions/checkout@v2
32+
uses: actions/checkout@v3
6933

70-
- name: Install Rust
71-
uses: actions-rs/toolchain@v1
34+
- name: Install Rust toolchain
35+
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1
7236
with:
37+
profile: minimal
7338
toolchain: stable
39+
components: clippy
7440
override: true
7541

76-
- name: Build code
77-
run: cargo build --all --release
78-
working-directory: ${{ env.working-directory }}
79-
80-
- name: Install required cargo
81-
run: cargo install clippy-sarif sarif-fmt
82-
83-
- name: Run rust-clippy
84-
run:
85-
cargo clippy
86-
--all-features
87-
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
88-
continue-on-error: true
89-
working-directory: ${{ env.working-directory }}
90-
91-
- name: Upload analysis results to GitHub
92-
uses: github/codeql-action/upload-sarif@v1
93-
with:
94-
sarif_file: ${{ env.working-directory }}/rust-clippy-results.sarif
95-
wait-for-processing: true
42+
- name: Install Dependencies
43+
run: sudo ./configure.sh -yd
9644

97-
rust-format:
98-
name: Rust Formatting Gate
99-
env:
100-
working-directory: "role-manager"
101-
runs-on: ubuntu-latest
102-
steps:
103-
- name: Checkout code
104-
uses: actions/checkout@v2
105-
106-
- name: Install Rust
107-
uses: actions-rs/toolchain@v1
45+
# if pull request review only
46+
- uses: mbrobbel/rustfmt-check@master
10847
with:
109-
toolchain: stable
110-
override: true
111-
- name: Build code
112-
run: cargo build --all --release
113-
working-directory: ${{ env.working-directory }}
114-
- name: Format code with Rustfmt
115-
run: cargo fmt --all -- --check
116-
working-directory: ${{ env.working-directory }}
48+
token: ${{ secrets.GITHUB_TOKEN }}
49+
continue-on-error: true #TODO: remove this line when rustfmt-check is fixed
11750

118-
rust-security:
119-
name: Rust Security Gate
120-
env:
121-
working-directory: "role-manager"
122-
runs-on: ubuntu-latest
123-
steps:
124-
- name: Checkout code
125-
uses: actions/checkout@v2
126-
127-
- name: Install Rust
128-
uses: actions-rs/toolchain@v1
51+
- uses: actions-rs/clippy-check@v1
12952
with:
130-
toolchain: stable
131-
override: true
132-
133-
- name: Cargo audit
134-
run: cargo audit --json | tee cargo-audit.json
135-
working-directory: ${{ env.working-directory }}
136-
id: cargo-audit
53+
token: ${{ secrets.GITHUB_TOKEN }}
54+
args: --all-features

.github/workflows/tests.yml

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,8 @@ on:
99
- 'main'
1010

1111
jobs:
12-
criterion:
13-
runs-on: ubuntu-latest
14-
15-
env:
16-
TEST: 1
17-
DEBUG: 1
18-
COV: 1
19-
20-
steps:
21-
- uses: actions/checkout@v2
22-
23-
- name: Update version
24-
run: sudo apt-get update
25-
- name: Install Dependencies
26-
run: sudo -E ./configure.sh
27-
- name: Build Unit Tests
28-
run: make -e build_unit_test
29-
- name: Run Unit Tests
30-
run: ./bin/unit_test
31-
- name: Upload coverage reports to Codecov
32-
uses: codecov/codecov-action@v3
33-
env:
34-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
35-
with:
36-
gcov: true
3712
rust-coverage:
3813
runs-on: ubuntu-latest
39-
needs: criterion # cannot upload concurrenlty to codecov
40-
env:
41-
working-directory: role-manager
4214
steps:
4315
- name: Checkout code
4416
uses: actions/checkout@v2
@@ -47,37 +19,31 @@ jobs:
4719
uses: actions-rs/toolchain@v1
4820
with:
4921
toolchain: stable
22+
components: llvm-tools-preview
5023
override: true
5124

5225
- name: Install grcov
53-
working-directory: ${{ env.working-directory }}
5426
run: cargo install grcov
5527

56-
- name: Install llvm-tools-preview
57-
working-directory: ${{ env.working-directory }}
58-
run: rustup component add llvm-tools-preview
59-
60-
- name: Build project for generating version.rs
61-
working-directory: ${{ env.working-directory }}
62-
run: cargo build
28+
- name: Install Dependencies
29+
run: sudo ./configure.sh -yd
6330

6431
- name: run tests with coverage
65-
working-directory: ${{ env.working-directory }}
6632
run: cargo test
6733
env:
34+
RUST_LOG: debug
6835
CARGO_INCREMENTAL: 0
6936
RUSTFLAGS: '-Cinstrument-coverage'
7037
LLVM_PROFILE_FILE: 'cargo-test-%p-%m.profraw'
7138
continue-on-error: true
7239

7340
- name: generate report
74-
working-directory: ${{ env.working-directory }}
75-
run: grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/debug/role-manager.lcov
41+
run: grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/debug/rootasrole.lcov
7642

7743
- name: Upload coverage reports to Codecov
7844
uses: codecov/codecov-action@v3
7945
env:
8046
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8147
with:
82-
file: role-manager/target/debug/role-manager.lcov
48+
file: target/debug/rootasrole.lcov
8349
flags: unittests

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
*.su
4444
*.idb
4545
*.pdb
46+
*.sarif
4647

4748
# Kernel Module Compile Results
4849
*.mod*
@@ -60,7 +61,7 @@ bin/
6061
# Hidden folders (for Linux IDE)
6162
/.idea/
6263
*target/
63-
version.rs
64+
*/src/xml_version.rs
6465

6566
# Rust crates
6667
Cargo.lock

.vscode/gdb_root.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
SELF_PATH=$(realpath -s "$0")
3+
4+
if [[ "$SUDO_ASKPASS" = "$SELF_PATH" ]]; then
5+
zenity --password --title="$1"
6+
else
7+
exec env SUDO_ASKPASS="$SELF_PATH" sudo -A /usr/bin/gdb $@
8+
fi

0 commit comments

Comments
 (0)