Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
18acffe
[MOSIP-29854] Creating dockerfile for dbvaluefinder script
Mahesh-Binayak Jan 11, 2024
7bb822e
Merge pull request #1 from Mahesh-Binayak/develop
Mahesh-Binayak Jan 11, 2024
f232b40
[MOSIP-29854] Updating directory
Mahesh-Binayak Jan 11, 2024
8dabb96
[MOSIP-29854] Updating filenames
Mahesh-Binayak Jan 11, 2024
1aa1c78
[MOSIP-29854]Created push_trigger.yml
Mahesh-Binayak Jan 11, 2024
07eb0c7
Merge branch 'develop' of https://github.com/mosip/security-tools int…
Mahesh-Binayak Jan 11, 2024
8ad0645
Merge branch 'develop' of https://github.com/mahesh-binayak/security-…
Mahesh-Binayak Jan 11, 2024
8130bd1
[MOSIP-29854] Updating filenames
Mahesh-Binayak Jan 11, 2024
bcc87bb
[MOSIP-29854] Updated push_trigger.yml
Mahesh-Binayak Jan 11, 2024
2a4fd2b
[MOSIP-29854] Updated push_trigger.yml
Mahesh-Binayak Jan 11, 2024
288f32b
[MOSIP-29854] Updated push_trigger.yml
Mahesh-Binayak Jan 11, 2024
9c17fca
[MOSIP-29854] Updated push_trigger.yml
Mahesh-Binayak Jan 11, 2024
bab1c4a
[MOSIP-29854] Updated push_trigger.yml
Mahesh-Binayak Jan 11, 2024
717ddb0
[MOSIP-29854] Updated push_trigger.yml
Mahesh-Binayak Jan 11, 2024
27de7eb
[MOSIP-29854] Updated push_trigger.yml
Mahesh-Binayak Jan 11, 2024
006f175
[MOSIP-29854] Updated push_trigger.yml
Mahesh-Binayak Jan 11, 2024
6608b0c
[MOSIP-29854] Updated push_trigger.yml
Mahesh-Binayak Jan 11, 2024
3cbe423
[MOSIP-29854] Updated port number
Mahesh-Binayak Jan 11, 2024
f45988d
Merge pull request #2 from Mahesh-Binayak/develop
Mahesh-Binayak Jan 11, 2024
751af3d
Added docker build job
VSIVAKALYAN Jan 11, 2024
36e4f64
Merge pull request #3 from VSIVAKALYAN/develop
Mahesh-Binayak Jan 11, 2024
c1a99c3
Revert "Added docker build job"
Mahesh-Binayak Jan 11, 2024
a04c0d9
Merge pull request #4 from mosip/revert-3-develop
Mahesh-Binayak Jan 11, 2024
fac2673
[MOSIP-29854] created own image
Mahesh-Binayak Jan 11, 2024
5e82dfc
[MOSIP-29854] created own image
Mahesh-Binayak Jan 11, 2024
09a30cd
[MOSIP-29854] created own image
Mahesh-Binayak Jan 11, 2024
220765c
[MOSIP-29854] created own image
Mahesh-Binayak Jan 11, 2024
c135419
[MOSIP-29854] created own image and updated script
Mahesh-Binayak Jan 12, 2024
de9f5b6
Merge pull request #5 from Mahesh-Binayak/update
Mahesh-Binayak Jan 12, 2024
fae2537
[MOSIP-29854] created own image and updated script
Mahesh-Binayak Jan 12, 2024
bb5b75d
Merge pull request #3 from Mahesh-Binayak/update
Mahesh-Binayak Jan 12, 2024
4f5737d
[MOSIP-29854] created own image and updated script
Mahesh-Binayak Jan 12, 2024
5e7a293
[MOSIP-29854] created own image and updated script
Mahesh-Binayak Jan 12, 2024
ddddfd7
Merge pull request #4 from Mahesh-Binayak/update
Mahesh-Binayak Jan 12, 2024
e3c6b57
[MOSIP-29854] created own image and updated script on update branch
Mahesh-Binayak Jan 18, 2024
57cdf22
[MOSIP-29854] created own image and updated script on update branch
Mahesh-Binayak Jan 18, 2024
de7f1ce
[MOSIP-29854] created own image and updated script on update branch
Mahesh-Binayak Jan 18, 2024
5d92313
[MOSIP-29854] created own image and updated script on update branch
Mahesh-Binayak Jan 18, 2024
238b76e
[MOSIP-29854] created own image and updated script on update branch
Mahesh-Binayak Jan 18, 2024
d0f8a8f
[MOSIP-29854] updated script on update branch
Mahesh-Binayak Jan 19, 2024
9e26907
[MOSIP-29854] updated script on update branch
Mahesh-Binayak Jan 19, 2024
d4a17d1
[MOSIP-29854] updated script on update branch
Mahesh-Binayak Jan 19, 2024
46f9ff4
[MOSIP-29854] updated script on update branch
Mahesh-Binayak Jan 19, 2024
9bf0f9f
[MOSIP-29854] updatepush_trigger and Dockerfile on update branch
Mahesh-Binayak Jan 25, 2024
4c8d924
[MOSIP-29854] updatepush_trigger and Dockerfile on update branch
Mahesh-Binayak Jan 25, 2024
1673f21
[MOSIP-29854]Renamed to lowercase
Mahesh-Binayak Jan 25, 2024
9551bd5
Merge pull request #6 from Mahesh-Binayak/update
ckm007 Jan 25, 2024
3b2505f
Merge pull request #7 from mosip/update
Mahesh-Binayak Jan 25, 2024
2cf5366
[MOSIP-29854]Updated regex and added db.properties
Mahesh-Binayak Feb 1, 2024
e85a684
[MOSIP-29854]Updated regex and added db.properties
Mahesh-Binayak Feb 1, 2024
9ae776d
[MOSIP-29854]Updated regex and added db.properties
Mahesh-Binayak Feb 1, 2024
8a77524
Merge pull request #8 from Mahesh-Binayak/update
Mahesh-Binayak Feb 1, 2024
e3363ad
[MOSIP-29854]Updated regex and added db.properties
Mahesh-Binayak Feb 1, 2024
c7e1374
[MOSIP-29854]Updated regex and added db.properties
Mahesh-Binayak Feb 1, 2024
3c03d0c
Merge pull request #9 from Mahesh-Binayak/update
Mahesh-Binayak Feb 1, 2024
8225896
[MOSIP-29854]Added PMS db to checklist
Mahesh-Binayak Feb 1, 2024
83f78a8
Merge pull request #10 from Mahesh-Binayak/update
Mahesh-Binayak Feb 1, 2024
4fa3421
[MOSIP-29854]Added PMS db to checklist
Mahesh-Binayak Feb 1, 2024
34e4334
Merge pull request #11 from Mahesh-Binayak/update
Mahesh-Binayak Feb 1, 2024
4b37897
Revert "[MOSIP-29854]Added PMS db to checklist"
Mahesh-Binayak Feb 1, 2024
6942eea
Merge pull request #12 from mosip/revert-11-update
Mahesh-Binayak Feb 1, 2024
b3fb0d8
[MOSIP-29854]Added PMS db to checklist
Mahesh-Binayak Feb 2, 2024
465ae0c
Merge pull request #13 from Mahesh-Binayak/update
Mahesh-Binayak Feb 2, 2024
41bd685
Merge pull request #5 from Mahesh-Binayak/update
Mahesh-Binayak Feb 8, 2024
6ad2504
Merge pull request #14 from Mahesh-Binayak/develop
Mahesh-Binayak Feb 8, 2024
c238be9
Merge pull request #15 from mosip/update
Mahesh-Binayak Feb 8, 2024
cb8cf0f
script enhancement
rajapandi1234 Mar 11, 2024
0e82c30
script enhancement
rajapandi1234 Mar 11, 2024
08c7546
script enhancement
rajapandi1234 Mar 11, 2024
47497c0
script enhancement
rajapandi1234 Mar 11, 2024
775ccd8
script enhancement
rajapandi1234 Mar 11, 2024
991c470
Merge pull request #18 from rajapandi1234/develop
Mahesh-Binayak Mar 14, 2024
6381233
[MOSIP-31232] added files for certificate check and update
Mahesh-Binayak Mar 25, 2024
79bf809
[MOSIP-31232] added files for certificate check and update
Mahesh-Binayak Mar 25, 2024
d303c93
[MOSIP-31232] added files for certificate check and update
Mahesh-Binayak Mar 27, 2024
976f971
[MOSIP-31232] added files for certificate check and update
Mahesh-Binayak Mar 27, 2024
4282e0f
[MOSIP-31232] added files for certificate check and update and named …
Mahesh-Binayak Mar 27, 2024
dacf269
[MOSIP-31232] Updated filename to renew
Mahesh-Binayak Mar 27, 2024
e33f9fb
[MOSIP-31232] Updated filename to check and completed dockerisation
Mahesh-Binayak Mar 28, 2024
d8973e0
[MOSIP-31232]added feature in certalert.py and will use that. SH scri…
Mahesh-Binayak Apr 5, 2024
d09b506
for snyk test
rajapandi1234 Apr 22, 2024
68abf74
Update push_trigger.yml
Mahesh-Binayak Apr 25, 2024
526b640
Update push_trigger.yml
Mahesh-Binayak Apr 25, 2024
3e9eeb1
[MOSIP-31232]added feature in certalert.py and will use that. SH scri…
Mahesh-Binayak Apr 25, 2024
b924a3d
[MOSIP-31232]Renamed files , tested with local docker image
Mahesh-Binayak Apr 26, 2024
6e55454
[MOSIP-31232]Created Push-trigger.yml
Mahesh-Binayak May 3, 2024
8461f5e
[MOSIP-31232]Updated Dockerfile
Mahesh-Binayak May 3, 2024
f6c28d0
[MOSIP-31232]Updated Dockerfile
Mahesh-Binayak May 3, 2024
5903356
Merge pull request #19 from Mahesh-Binayak/mbupdates
Mahesh-Binayak May 3, 2024
4448d53
[MOSIP-31232]Updated Dockerfile
Mahesh-Binayak May 3, 2024
26e1d49
[MOSIP-31232]Updated checkupdate.py
Mahesh-Binayak May 21, 2024
da574c4
Merge pull request #20 from Mahesh-Binayak/mbupdates
Mahesh-Binayak May 21, 2024
f1ffd3c
fix: databreachdetector/Dockerfile to reduce vulnerabilities
snyk-bot Jun 27, 2024
92f8347
Merge pull request #2 from rajapandi1234/snyk-fix-27c439a74d734a29b7f…
rajapandi1234 Jun 27, 2024
57d821d
Update databreachdetector.py
rajapandi1234 Jul 11, 2024
02904e1
Revert "[Snyk] Security upgrade python from 3.9 to 3.13.0b1-slim"
rajapandi1234 Jul 11, 2024
b532155
Update requirements.txt
rajapandi1234 Jul 11, 2024
00fcc72
Merge pull request #22 from rajapandi1234/develop
Mahesh-Binayak Jul 11, 2024
b765e94
[MOSIP-35490] moved required helm and deploy scripts to modular repo
ckm007 Dec 3, 2024
c11e70e
[[MOSIP-35490] moved required helm and deploy scripts to modular repo…
Prafulrakhade Dec 4, 2024
22f7041
[MOSIP-35490] moved required helm and deploy scripts to modular]
Prafulrakhade Dec 4, 2024
7a3157c
Merge pull request #29 from Prafulrakhade/ckm007-patch-2
ckm007 Dec 4, 2024
28adca4
Merge pull request #30 from mosip/develop2
Mahesh-Binayak Dec 4, 2024
111bbbb
Merge pull request #28 from mosip/ckm007-patch-2
ckm007 Dec 5, 2024
cd44539
Update README.md
Mahesh-Binayak Dec 10, 2024
307aba5
[MOSIP-39249] added option to get partner-id input from an env variable
Mahesh-Binayak Feb 4, 2025
56bf2af
Merge pull request #31 from Mahesh-Binayak/develop2
Mahesh-Binayak Feb 4, 2025
9c1b40b
Merge branch 'develop2' of https://github.com/mosip/security-tools in…
Mar 19, 2025
0d6049d
[MOSIP-32088]added changes
Mahesh-Binayak Mar 25, 2025
68cb197
Merge pull request #32 from Mahesh-Binayak/develop2
Mahesh-Binayak Mar 25, 2025
c9916d7
[MOSIP-32088]added changes
Apr 9, 2025
cd5af64
Merge pull request #33 from Mahesh-Binayak/develop2
Mahesh-Binayak Apr 9, 2025
b246026
[MOSIP-41596]Updated the code to check for all partners.
Mahesh-Binayak May 30, 2025
28ecd39
Merge branch 'develop2' of https://github.com/mahesh-binayak/security…
May 30, 2025
e2c165d
Merge pull request #34 from Mahesh-Binayak/develop2
Mahesh-Binayak Jun 2, 2025
1b4d93d
[MOSIP-41897]adding dummy sonar code for pr check.
Mahesh-Binayak Jun 18, 2025
afcb768
Merge pull request #35 from Mahesh-Binayak/develop
ckm007 Jun 19, 2025
9bf0eff
[MOSIP-41897]adding dummy sonar code for pr check.
Mahesh-Binayak Jul 16, 2025
6df2c0d
[MOSIP-32607]Update bootstrap.properties
Mahesh-Binayak Jul 21, 2025
06a3a2e
Merge pull request #36 from Mahesh-Binayak/develop2
ckm007 Jul 22, 2025
68ae63c
[MOSIP-32607] updated helm charts
web-flow Jul 22, 2025
0e88b80
[MOSIP-32607] updated helm charts
Rakshithb1 Jul 23, 2025
b54fda5
[MOSIP-32607] updated added cluster role
Rakshithb1 Jul 23, 2025
de11ce8
[MOSIP-32607] updated added cluster role
Rakshithb1 Jul 23, 2025
17d35f0
[MOSIP-32607] updated added cluster role
Rakshithb1 Jul 23, 2025
3788a50
Merge pull request #37 from Rakshithb1/MOSIP-32607
ckm007 Jul 23, 2025
d6d81a6
[MOSIP-32607] updated host
Rakshithb1 Jul 23, 2025
de426b8
Merge pull request #38 from Rakshithb1/MOSIP-32607
ckm007 Jul 24, 2025
6084c63
[MOSIP-32607]
Rakshithb1 Jul 28, 2025
fc25dbc
Merge pull request #40 from Rakshithb1/MOSIP-32607
Mahesh-Binayak Jul 28, 2025
6637977
[MOSIP-32607] corrected helm path
Rakshithb1 Jul 28, 2025
bb11230
Merge pull request #41 from Rakshithb1/MOSIP-32607
Mahesh-Binayak Jul 28, 2025
f91d4c2
[MOSIP-32607]
Rakshithb1 Jul 28, 2025
d13e79e
Merge pull request #42 from Rakshithb1/MOSIP-32607
Mahesh-Binayak Jul 28, 2025
93e8bb5
[MOSIP-32607] added values.yaml in install.sh
Rakshithb1 Jul 28, 2025
d89f95d
Merge pull request #44 from Rakshithb1/MOSIP-32607
Mahesh-Binayak Jul 29, 2025
6e3bee9
[MOSIP-32607] updated values.yaml
Rakshithb1 Jul 30, 2025
18d8215
[MOSIP-32607] updated values.yaml
Rakshithb1 Jul 30, 2025
d573a26
Merge pull request #45 from Rakshithb1/MOSIP-32607
Mahesh-Binayak Jul 30, 2025
8685b38
[MOSIP-32607]
Rakshithb1 Aug 6, 2025
adae46b
Merge pull request #47 from Rakshithb1/MOSIP-32607
Mahesh-Binayak Aug 6, 2025
90e16fe
[MOSIP-32607] added README.md
Mahesh-Binayak Aug 6, 2025
12013a1
Merge pull request #48 from Mahesh-Binayak/develop
ckm007 Aug 7, 2025
1d34318
[MOSIP-43032] added auditsweeper tool along with its helm charts.
Mahesh-Binayak Sep 24, 2025
eae51af
[MOSIP-43032] added missing . in dockerfile.
Mahesh-Binayak Sep 24, 2025
60dccc5
[MOSIP-43032] added missing . in dockerfile.
Mahesh-Binayak Sep 24, 2025
3deaa7f
[MOSIP-43032] Optimized dockerfile and updated properties.
Mahesh-Binayak Sep 24, 2025
0849b17
Merge pull request #51 from Mahesh-Binayak/MOSIP-43032
ckm007 Oct 6, 2025
73c3fae
[MOSIP-43032] Updated auditsweeper.py
Mahesh-Binayak Oct 15, 2025
1cb1183
Merge pull request #52 from Mahesh-Binayak/MOSIP-43032
ckm007 Oct 15, 2025
7504c84
[MOSIP-43032] Updated auditsweeper's permissions ,image names and con…
Mahesh-Binayak Oct 16, 2025
b97b7b2
Merge pull request #53 from Mahesh-Binayak/MOSIP-43032
ckm007 Oct 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/chart-lint-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Validate / Publish helm charts

on:
release:
types: [published]
pull_request:
types: [opened, reopened, synchronize]
paths:
- 'helm/**'
workflow_dispatch:
inputs:
IGNORE_CHARTS:
description: 'Provide list of charts to be ignored separated by pipe(|)'
required: false
default: '""'
type: string
CHART_PUBLISH:
description: 'Chart publishing to gh-pages branch'
required: false
default: 'NO'
type: string
options:
- YES
- NO
INCLUDE_ALL_CHARTS:
description: 'Include all charts for Linting/Publishing (YES/NO)'
required: false
default: 'NO'
type: string
options:
- YES
- NO
push:
branches:
- '!release-branch'
- '!master'
- 1.*
- 0.*
- develop
- MOSIP*
- release*
paths:
- 'helm/**'

jobs:
chart-lint-publish:
uses: mosip/kattu/.github/workflows/chart-lint-publish.yml@master
with:
CHARTS_DIR: ./helm
CHARTS_URL: https://mosip.github.io/mosip-helm
REPOSITORY: mosip-helm
BRANCH: gh-pages
INCLUDE_ALL_CHARTS: "${{ inputs.INCLUDE_ALL_CHARTS || 'NO' }}"
IGNORE_CHARTS: "${{ inputs.IGNORE_CHARTS || '\"\"' }}"
CHART_PUBLISH: "${{ inputs.CHART_PUBLISH || 'YES' }}"
LINTING_CHART_SCHEMA_YAML_URL: "https://raw.githubusercontent.com/mosip/kattu/master/.github/helm-lint-configs/chart-schema.yaml"
LINTING_LINTCONF_YAML_URL: "https://raw.githubusercontent.com/mosip/kattu/master/.github/helm-lint-configs/lintconf.yaml"
LINTING_CHART_TESTING_CONFIG_YAML_URL: "https://raw.githubusercontent.com/mosip/kattu/master/.github/helm-lint-configs/chart-testing-config.yaml"
LINTING_HEALTH_CHECK_SCHEMA_YAML_URL: "https://raw.githubusercontent.com/mosip/kattu/master/.github/helm-lint-configs/health-check-schema.yaml"
secrets:
TOKEN: ${{ secrets.ACTION_PAT }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
47 changes: 47 additions & 0 deletions .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Building Security Tools

on:
release:
types: [published]
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:
inputs:
message:
description: 'Message for manually triggering'
required: false
default: 'Triggered for Updates'
type: string
push:
branches:
- master
- 1.*
- develop*
- release*
- MOSIP*
- update

jobs:
build-dockers:
strategy:
matrix:
include:
- SERVICE_LOCATION: 'databreachdetector'
SERVICE_NAME: 'databreachdetector'
- SERVICE_LOCATION: 'certmanager'
SERVICE_NAME: 'certmanager'
- SERVICE_LOCATION: 'auditsweeper'
SERVICE_NAME: 'auditsweeper'
ONLY_DOCKER: true
fail-fast: false
name: ${{ matrix.SERVICE_NAME }}
uses: mosip/kattu/.github/workflows/docker-build.yml@master
with:
SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }}
SERVICE_NAME: ${{ matrix.SERVICE_NAME }}
ONLY_DOCKER: ${{ matrix.ONLY_DOCKER }}
secrets:
DEV_NAMESPACE_DOCKER_HUB: ${{ secrets.DEV_NAMESPACE_DOCKER_HUB }}
ACTOR_DOCKER_HUB: ${{ secrets.ACTOR_DOCKER_HUB }}
RELEASE_DOCKER_HUB: ${{ secrets.RELEASE_DOCKER_HUB }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_DEVOPS }}
41 changes: 41 additions & 0 deletions .github/workflows/sonar-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: SonarCloud PR Quality Gate

on:
push:
branches:
- develop

jobs:
sonar_analysis:
name: maven-sonar-analysis
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'

- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Run SonarCloud analysis
env:
SONAR_TOKEN: f4e496ee8ddc6661404844949201593f56078e94
run: |
mvn -B verify sonar:sonar -Dsonar.projectKey=mosip_security-tools -Dsonar.organization=mosip -Dsonar.host.url=https://sonarcloud.io -DskipSigning=true
Comment on lines +10 to +41

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

To fix the issue, add a permissions block to the job definition at .github/workflows/sonar-check.yml under the sonar_analysis job (line 10). The minimal recommended permission for most CI analysis workflows is contents: read, which allows the job to read source code but not to push, modify, or delete repository content. As none of the steps in this job require write permissions to repository contents, using contents: read is the most secure and appropriate setting.

Change summary:

  • Insert a permissions: block (with contents: read) below name: maven-sonar-analysis (line 10) and above runs-on: ubuntu-latest (line 11).
Suggested changeset 1
.github/workflows/sonar-check.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/sonar-check.yml b/.github/workflows/sonar-check.yml
--- a/.github/workflows/sonar-check.yml
+++ b/.github/workflows/sonar-check.yml
@@ -8,6 +8,8 @@
 jobs:
   sonar_analysis:
     name: maven-sonar-analysis
+    permissions:
+      contents: read
     runs-on: ubuntu-latest
 
     steps:
EOF
@@ -8,6 +8,8 @@
jobs:
sonar_analysis:
name: maven-sonar-analysis
permissions:
contents: read
runs-on: ubuntu-latest

steps:
Copilot is powered by AI and may make mistakes. Always verify output.
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

39 changes: 39 additions & 0 deletions auditsweeper/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM python:3.9

ARG SOURCE
ARG COMMIT_HASH
ARG COMMIT_ID
ARG BUILD_TIME
LABEL source=${SOURCE}
LABEL commit_hash=${COMMIT_HASH}
LABEL commit_id=${COMMIT_ID}
LABEL build_time=${BUILD_TIME}

ARG container_user=mosip
ARG container_user_group=mosip
ARG container_user_uid=1001
ARG container_user_gid=1001

# Create the user and set the working directory
RUN groupadd -r ${container_user_group} && useradd -u ${container_user_uid} -r -g ${container_user_group} -s /bin/bash -m -d /home/${container_user} ${container_user}

WORKDIR /home/${container_user}

# Add all files to the correct working directory
ADD . .

# Install kubectl and Python dependencies
RUN apt-get -y update && apt-get install -y curl \
&& curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.sio/release/stable.txt)/bin/linux/amd64/kubectl" \
&& chmod +x ./kubectl && mv ./kubectl /usr/local/bin/kubectl \
&& pip install --no-cache-dir -r requirements.txt \
&& chown -R ${container_user}:${container_user_group} /home/${container_user}

USER ${container_user}

ENV db-server=
ENV db-port=
ENV db-su-user=
ENV postgres-password=

CMD ["python", "auditsweeper.py"]
87 changes: 87 additions & 0 deletions auditsweeper/auditsweeper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import os
import sys
import configparser
import psycopg2

# This script performs a cleanup of old log entries from a PostgreSQL database.
# It is designed to be run as a Docker container via a cron job.

def get_db_credentials():
"""
Attempts to get database credentials from environment variables.
If not found, falls back to a local.properties file.
"""
# List of required variables
required_vars = [
"db-host", "db-port", "db-su-user",
"postgres-password", "log-age-days"
]

env_vars = {var: os.getenv(var) for var in required_vars}

# Check if all environment variables are set
if all(env_vars.values()):
print("Using credentials from environment variables.")
return env_vars
else:
print("One or more required environment variables are not set. Checking for local.properties...")
config = configparser.ConfigParser()
config_file = "local.properties"

if not os.path.exists(config_file):
print(f"Error: Required variables not set and '{config_file}' not found.")
sys.exit(1)

try:
# Read the properties file, assuming a single section
config.read_string(f"[DEFAULT]\n{open(config_file).read()}")
props = config['DEFAULT']

# Populate variables from the properties file
return {var: props.get(var) for var in required_vars}
except configparser.Error as e:
print(f"Error reading local.properties file: {e}")
sys.exit(1)

def cleanup_db(config):
"""
Connects to the database and performs the cleanup operation.
"""
db_name = "mosip_audit"
try:
conn = psycopg2.connect(
host=config["db-host"],
port=config["db-port"],
user=config["db-su-user"],
password=config["postgres-password"],
dbname=db_name
)
cur = conn.cursor()

print(f"Starting database cleanup for logs older than {config['log-age-days']} days...")
print(f"Connecting to DB: {config['db-su-user']}@{config['db-host']}:{config['db-port']}/{db_name}")

# The core DELETE command
# Use a parameterized query for safety
delete_query = "DELETE FROM audit.app_audit_log WHERE log_dtimes < NOW() - INTERVAL %s"
interval_str = f"{config['log-age-days']} days"

cur.execute(delete_query, (interval_str,))

# Get the number of rows deleted
rows_deleted = cur.rowcount
conn.commit()

print(f"Successfully deleted {rows_deleted} rows.")

except psycopg2.OperationalError as e:
print(f"Database connection or query failed: {e}")
sys.exit(1)
finally:
if 'conn' in locals() and conn:
conn.close()

if __name__ == "__main__":
db_config = get_db_credentials()
cleanup_db(db_config)
print("Database cleanup script finished successfully.")
5 changes: 5 additions & 0 deletions auditsweeper/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
db-host=postgres.dev1.mosip.net
db-port=5432
db-su-user=postgres
postgres-password=HEdM***9ZXir7Tu2F
log-age-days=85
1 change: 1 addition & 0 deletions auditsweeper/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
psycopg2-binary==2.9.1
46 changes: 46 additions & 0 deletions certmanager/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM python:3.9

ARG SOURCE
ARG COMMIT_HASH
ARG COMMIT_ID
ARG BUILD_TIME
LABEL source=${SOURCE}
LABEL commit_hash=${COMMIT_HASH}
LABEL commit_id=${COMMIT_ID}
LABEL build_time=${BUILD_TIME}

ARG container_user=mosip
ARG container_user_group=mosip
ARG container_user_uid=1001
ARG container_user_gid=1001

# Install kubectl binary
RUN apt-get -y update \
&& apt-get install -y curl \
&& curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
&& chmod +x ./kubectl && mv ./kubectl /usr/local/bin/kubectl

# Create user group
RUN groupadd -r ${container_user_group} && useradd -u ${container_user_uid} -r -g ${container_user_group} -s /bin/bash -m -d /home/${container_user} ${container_user}
RUN chown -R ${container_user}:${container_user} /home/${container_user}
WORKDIR /home/${container_user}
USER ${container_user}

ENV MYDIR=`pwd`
ENV DATE="$(date --utc +%FT%T.%3NZ)"
ENV ENABLE_INSECURE=false
ENV MODULE=


ENV db-server=
ENV db-port=
ENV db-su-user=
ENV postgres-password=
ENV ns_esignet=esignet

COPY partner.properties .
COPY requirements.txt .
COPY checkupdate.py .
COPY bootstrap.properties .
RUN pip install --no-cache-dir -r requirements.txt
CMD ["python", "checkupdate.py"]
Loading