From a10cc758bef7d0c200d3ace48c19bf00dfa595dc Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Sat, 6 Aug 2022 19:53:06 -0300 Subject: [PATCH 01/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index fa3b928..063b0ec 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -24,3 +24,11 @@ jobs: timeout-minutes: 5 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: Get Sonar Status and comment PR + if: () + uses: campos-pay/Sonar-status-check@main + with: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_PROJETCKEY: python-app + GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} From 6a1f8955fcf97fd4a2b5f13083fab946b90e9ad3 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Sat, 6 Aug 2022 19:53:32 -0300 Subject: [PATCH 02/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 063b0ec..aecd5a8 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -1,6 +1,6 @@ name: Sonar Qube Scan on: - workflow_dispatch: + pull_request: jobs: sonarcloud: From a8425368980faef4639eba4dba17da7d344e5b71 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Sat, 6 Aug 2022 19:55:47 -0300 Subject: [PATCH 03/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index aecd5a8..af15329 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -25,7 +25,7 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - name: Get Sonar Status and comment PR - if: () + if: failure() uses: campos-pay/Sonar-status-check@main with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 225852906a439261dcbb30cce7d023b0151adee3 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Sat, 6 Aug 2022 20:01:18 -0300 Subject: [PATCH 04/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index af15329..5057f94 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -29,6 +29,6 @@ jobs: uses: campos-pay/Sonar-status-check@main with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_URL: ${{ secrets.SONAR_HOST_URL }} SONAR_PROJETCKEY: python-app GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} From 8aaf2624ab8d8ba8aa02cbd2d762d8eec78a6856 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Sun, 7 Aug 2022 20:01:53 -0300 Subject: [PATCH 05/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 5057f94..617ce7e 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -24,6 +24,7 @@ jobs: timeout-minutes: 5 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + #Test Sonar - name: Get Sonar Status and comment PR if: failure() uses: campos-pay/Sonar-status-check@main From ce902955e5b2684adf5b76af921a57dc8a33316f Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Sun, 7 Aug 2022 20:21:28 -0300 Subject: [PATCH 06/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 617ce7e..802d599 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -24,7 +24,7 @@ jobs: timeout-minutes: 5 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - #Test Sonar + #Test Sonar Script - name: Get Sonar Status and comment PR if: failure() uses: campos-pay/Sonar-status-check@main From 51d4145c2b545ba593bfb7fec182ad465150394c Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Sun, 7 Aug 2022 20:25:41 -0300 Subject: [PATCH 07/66] Create testsonar.py --- telegram_bot/networking/testsonar.py | 128 +++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 telegram_bot/networking/testsonar.py diff --git a/telegram_bot/networking/testsonar.py b/telegram_bot/networking/testsonar.py new file mode 100644 index 0000000..5c21dbf --- /dev/null +++ b/telegram_bot/networking/testsonar.py @@ -0,0 +1,128 @@ +# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() From b1d044c08cea85f53af96726d6a506e27c4b2fd0 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Tue, 9 Aug 2022 20:43:14 -0300 Subject: [PATCH 08/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 802d599..9baad31 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -20,16 +20,16 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - name: SonarQube Quality Gate check - uses: sonarsource/sonarqube-quality-gate-action@master + uses: campos-pay/sonarqube-quality-gate-action@master timeout-minutes: 5 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} #Test Sonar Script - - name: Get Sonar Status and comment PR - if: failure() - uses: campos-pay/Sonar-status-check@main - with: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_PROJETCKEY: python-app - GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} +# - name: Get Sonar Status and comment PR +# if: failure() +# uses: campos-pay/Sonar-status-check@main +# with: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} +# SONAR_PROJETCKEY: python-app +# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} From 93eced9e04a671784b8c3f1061946d483fe3bc3c Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 11 Aug 2022 20:55:57 -0300 Subject: [PATCH 09/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 9baad31..4f869de 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -24,6 +24,7 @@ jobs: timeout-minutes: 5 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} #Test Sonar Script # - name: Get Sonar Status and comment PR # if: failure() From 4e23b0e2b624321e14154acfbb92dfed5feadb09 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 11 Aug 2022 21:03:17 -0300 Subject: [PATCH 10/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 4f869de..337d24f 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -22,9 +22,11 @@ jobs: - name: SonarQube Quality Gate check uses: campos-pay/sonarqube-quality-gate-action@master timeout-minutes: 5 + with: + GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + #Test Sonar Script # - name: Get Sonar Status and comment PR # if: failure() From a7e9381ba74acd1f3e98f72558194b0c516c438f Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 11 Aug 2022 21:11:39 -0300 Subject: [PATCH 11/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 337d24f..551eef2 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -28,11 +28,11 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} #Test Sonar Script -# - name: Get Sonar Status and comment PR -# if: failure() -# uses: campos-pay/Sonar-status-check@main -# with: -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} -# SONAR_PROJETCKEY: python-app -# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get Sonar Status and comment PR + if: success() + uses: campos-pay/Sonar-status-check@main + with: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_PROJETCKEY: python-app + GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} From 1dc4c1dccf71b2a221979ffd8647a4ef5e8732a8 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Wed, 17 Aug 2022 22:10:26 -0300 Subject: [PATCH 12/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 35 ++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 551eef2..b513755 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -21,18 +21,31 @@ jobs: SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - name: SonarQube Quality Gate check uses: campos-pay/sonarqube-quality-gate-action@master + id: sonar timeout-minutes: 5 - with: - GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} +# with: +# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - #Test Sonar Script - - name: Get Sonar Status and comment PR - if: success() - uses: campos-pay/Sonar-status-check@main + - name: PR Comment + uses: actions/github-script@v2 with: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_PROJETCKEY: python-app - GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.issues.createComment({ + issue_number: ${{ github.event.number }}, + owner: context.repo.owner, + repo: context.repo.repo, + body: `👋 Ola se voce esta vendo esse erro tem algo errado na sua PR verifique o SonarQube para mais detalhes :warning: + ${{ steps.sonar.outputs.quality_status }}` + }) + + #Test Sonar Script +# - name: Get Sonar Status and comment PR +# if: success() +# uses: campos-pay/Sonar-status-check@main +# with: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} +# SONAR_PROJETCKEY: python-app +# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} From 04775a13f70ad5106c99db6cda4dd15fbab7715f Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Wed, 17 Aug 2022 22:25:44 -0300 Subject: [PATCH 13/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index b513755..41f8d7f 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -37,7 +37,7 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, body: `👋 Ola se voce esta vendo esse erro tem algo errado na sua PR verifique o SonarQube para mais detalhes :warning: - ${{ steps.sonar.outputs.quality_status }}` + ${{ steps.sonar.outputs.quality-gate-status }}👋` }) #Test Sonar Script From 2f80604cb2e880523129df9f6d6b6e1c17b65ea4 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Wed, 17 Aug 2022 22:44:43 -0300 Subject: [PATCH 14/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 41f8d7f..7f12df0 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -27,25 +27,25 @@ jobs: # GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: PR Comment - uses: actions/github-script@v2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.issues.createComment({ - issue_number: ${{ github.event.number }}, - owner: context.repo.owner, - repo: context.repo.repo, - body: `👋 Ola se voce esta vendo esse erro tem algo errado na sua PR verifique o SonarQube para mais detalhes :warning: - ${{ steps.sonar.outputs.quality-gate-status }}👋` - }) +# - name: PR Comment +# uses: actions/github-script@v2 +# with: +# github-token: ${{ secrets.GITHUB_TOKEN }} +# script: | +# github.issues.createComment({ +# issue_number: ${{ github.event.number }}, +# owner: context.repo.owner, +# repo: context.repo.repo, +# body: `👋 Ola se voce esta vendo esse erro tem algo errado na sua PR verifique o SonarQube para mais detalhes :warning: +# ${{ steps.sonar.outputs.quality-gate-status }}👋` +# }) #Test Sonar Script -# - name: Get Sonar Status and comment PR -# if: success() -# uses: campos-pay/Sonar-status-check@main -# with: -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} -# SONAR_PROJETCKEY: python-app -# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get Sonar Status and comment PR + if: success() + uses: campos-pay/Sonar-status-check@main + with: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_PROJETCKEY: python-app + GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} From ff217340b251136160ff334c9404775a3866f1a6 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Wed, 17 Aug 2022 23:24:30 -0300 Subject: [PATCH 15/66] Delete testsonar.py --- telegram_bot/networking/testsonar.py | 128 --------------------------- 1 file changed, 128 deletions(-) delete mode 100644 telegram_bot/networking/testsonar.py diff --git a/telegram_bot/networking/testsonar.py b/telegram_bot/networking/testsonar.py deleted file mode 100644 index 5c21dbf..0000000 --- a/telegram_bot/networking/testsonar.py +++ /dev/null @@ -1,128 +0,0 @@ -# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() From de5c27ff770dfc51a974c93cd35f54cc2a574e24 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Fri, 19 Aug 2022 23:16:46 -0300 Subject: [PATCH 16/66] Create testesonar.py --- telegram_bot/networking/testesonar.py | 255 ++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 telegram_bot/networking/testesonar.py diff --git a/telegram_bot/networking/testesonar.py b/telegram_bot/networking/testesonar.py new file mode 100644 index 0000000..942fecd --- /dev/null +++ b/telegram_bot/networking/testesonar.py @@ -0,0 +1,255 @@ +# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy()# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() From a38ccb052267819d0ee1480bfa7d914d009ed544 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Fri, 19 Aug 2022 23:57:02 -0300 Subject: [PATCH 17/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 7f12df0..a169f23 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -20,29 +20,19 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - name: SonarQube Quality Gate check - uses: campos-pay/sonarqube-quality-gate-action@master + uses: sonarsource/sonarqube-quality-gate-action@master id: sonar timeout-minutes: 5 -# with: -# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# - name: PR Comment -# uses: actions/github-script@v2 -# with: -# github-token: ${{ secrets.GITHUB_TOKEN }} -# script: | -# github.issues.createComment({ -# issue_number: ${{ github.event.number }}, -# owner: context.repo.owner, -# repo: context.repo.repo, -# body: `👋 Ola se voce esta vendo esse erro tem algo errado na sua PR verifique o SonarQube para mais detalhes :warning: -# ${{ steps.sonar.outputs.quality-gate-status }}👋` -# }) + # Optionally you can use the output from the Quality Gate in another step. + # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. + - name: "Example show SonarQube Quality Gate Status value" + run: echo "The Quality Gate status is ${{ steps.sonar.outputs.quality-gate-status }}" #Test Sonar Script - name: Get Sonar Status and comment PR - if: success() + if: always() uses: campos-pay/Sonar-status-check@main with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 4aac21c040fda28e2df693776ea6a2f7363669df Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Sat, 20 Aug 2022 00:07:40 -0300 Subject: [PATCH 18/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index a169f23..0c25070 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -28,6 +28,7 @@ jobs: # Optionally you can use the output from the Quality Gate in another step. # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. - name: "Example show SonarQube Quality Gate Status value" + if: always() run: echo "The Quality Gate status is ${{ steps.sonar.outputs.quality-gate-status }}" #Test Sonar Script From fa9bcbf2aa4bdec6bbc8415ed7fb726216aa7a36 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 25 Aug 2022 21:26:46 -0300 Subject: [PATCH 19/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 0c25070..1626c8a 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -32,11 +32,17 @@ jobs: run: echo "The Quality Gate status is ${{ steps.sonar.outputs.quality-gate-status }}" #Test Sonar Script - - name: Get Sonar Status and comment PR - if: always() - uses: campos-pay/Sonar-status-check@main +# - name: Get Sonar Status and comment PR +# if: always() +# uses: campos-pay/Sonar-status-check@main +# with: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} +# SONAR_PROJETCKEY: python-app +# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Scan code + uses: vtex/action-sonarqube@main with: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_PROJETCKEY: python-app - GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + githubToken: ${{ secrets.GITHUB_TOKEN }} # https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret + host: ${{ secrets.SONAR_HOST_URL }} # Variable set in the Github Secrets + token: ${{ secrets.SONAR_TOKEN }} # Variable set in the Github Secrets From 725bebef2fc92c1faf2fbd600ab9821205284470 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 25 Aug 2022 21:29:12 -0300 Subject: [PATCH 20/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 1626c8a..c34f8fc 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -25,12 +25,6 @@ jobs: timeout-minutes: 5 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # Optionally you can use the output from the Quality Gate in another step. - # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. - - name: "Example show SonarQube Quality Gate Status value" - if: always() - run: echo "The Quality Gate status is ${{ steps.sonar.outputs.quality-gate-status }}" - #Test Sonar Script # - name: Get Sonar Status and comment PR # if: always() @@ -41,6 +35,7 @@ jobs: # SONAR_PROJETCKEY: python-app # GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Scan code + if: always() uses: vtex/action-sonarqube@main with: githubToken: ${{ secrets.GITHUB_TOKEN }} # https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret From 1f504a4225c8201810b01878eadddc20ab1f63fc Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 25 Aug 2022 21:34:07 -0300 Subject: [PATCH 21/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index c34f8fc..4d744de 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -38,6 +38,7 @@ jobs: if: always() uses: vtex/action-sonarqube@main with: + projectKey: python-app githubToken: ${{ secrets.GITHUB_TOKEN }} # https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret host: ${{ secrets.SONAR_HOST_URL }} # Variable set in the Github Secrets token: ${{ secrets.SONAR_TOKEN }} # Variable set in the Github Secrets From afd19c74b42e1feff8aa653ccf9456c2c8bdd716 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 25 Aug 2022 21:38:26 -0300 Subject: [PATCH 22/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 4d744de..149d7e3 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -26,19 +26,12 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} #Test Sonar Script -# - name: Get Sonar Status and comment PR -# if: always() -# uses: campos-pay/Sonar-status-check@main -# with: -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} -# SONAR_PROJETCKEY: python-app -# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Scan code + - name: Get Sonar Status and comment PR if: always() - uses: vtex/action-sonarqube@main + uses: campos-pay/Sonar-status-check@main with: - projectKey: python-app - githubToken: ${{ secrets.GITHUB_TOKEN }} # https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret - host: ${{ secrets.SONAR_HOST_URL }} # Variable set in the Github Secrets - token: ${{ secrets.SONAR_TOKEN }} # Variable set in the Github Secrets + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_PROJETCKEY: python-app + GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + From 2d855c0f48e3ef5344497e75fb391f7355a7ca6d Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 25 Aug 2022 21:45:40 -0300 Subject: [PATCH 23/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 149d7e3..f2b6a38 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -35,3 +35,16 @@ jobs: SONAR_PROJETCKEY: python-app GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Sonar Quality Gate + uses: dieuhd/sonar-quality-gate@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_URL: "https://api.github.com" + GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_PROJECT_KEY: python-app + with: + login: ${{ secrets.SONAR_TOKEN }} + url: ${{ secrets.SONAR_HOST_URL }} + projectKey: python-app From a64dbd67745264dd650fc60459ce1a3475fb0878 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 25 Aug 2022 21:48:25 -0300 Subject: [PATCH 24/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index f2b6a38..0924f49 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -26,16 +26,17 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} #Test Sonar Script - - name: Get Sonar Status and comment PR - if: always() - uses: campos-pay/Sonar-status-check@main - with: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_PROJETCKEY: python-app - GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} +# - name: Get Sonar Status and comment PR +# if: always() +# uses: campos-pay/Sonar-status-check@main +# with: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} +# SONAR_PROJETCKEY: python-app +# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up Sonar Quality Gate + if: always() uses: dieuhd/sonar-quality-gate@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From bf133f8171ca5848e5475db9a935a01299ffac56 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 25 Aug 2022 21:51:43 -0300 Subject: [PATCH 25/66] Create sonar-scan.yml From af90f05d695bfff27ad86603147a858d25aaa322 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 25 Aug 2022 21:58:17 -0300 Subject: [PATCH 26/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 0924f49..149d7e3 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -26,26 +26,12 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} #Test Sonar Script -# - name: Get Sonar Status and comment PR -# if: always() -# uses: campos-pay/Sonar-status-check@main -# with: -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} -# SONAR_PROJETCKEY: python-app -# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Sonar Quality Gate + - name: Get Sonar Status and comment PR if: always() - uses: dieuhd/sonar-quality-gate@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GIT_URL: "https://api.github.com" - GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_PROJECT_KEY: python-app + uses: campos-pay/Sonar-status-check@main with: - login: ${{ secrets.SONAR_TOKEN }} - url: ${{ secrets.SONAR_HOST_URL }} - projectKey: python-app + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_PROJETCKEY: python-app + GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + From f0c1d0175403c0ad4a3547109e8d9f3fe80cc026 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Mon, 29 Aug 2022 22:07:16 -0300 Subject: [PATCH 27/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 149d7e3..8a6ed1d 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -20,18 +20,20 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - name: SonarQube Quality Gate check - uses: sonarsource/sonarqube-quality-gate-action@master + uses: campos-pay/sonarqube-quality-gate-action@master id: sonar timeout-minutes: 5 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - #Test Sonar Script - - name: Get Sonar Status and comment PR - if: always() - uses: campos-pay/Sonar-status-check@main with: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_PROJETCKEY: python-app GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + #Test Sonar Script +# - name: Get Sonar Status and comment PR +# if: always() +# uses: campos-pay/Sonar-status-check@main +# with: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} +# SONAR_PROJETCKEY: python-app +# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} From 75e5e9286667f3d130c637c257a1653f5430f1ab Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Mon, 29 Aug 2022 23:06:55 -0300 Subject: [PATCH 28/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 8a6ed1d..b699cd7 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -19,21 +19,21 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - - name: SonarQube Quality Gate check - uses: campos-pay/sonarqube-quality-gate-action@master - id: sonar - timeout-minutes: 5 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} - #Test Sonar Script -# - name: Get Sonar Status and comment PR -# if: always() -# uses: campos-pay/Sonar-status-check@main +# - name: SonarQube Quality Gate check +# uses: campos-pay/sonarqube-quality-gate-action@master +# id: sonar +# timeout-minutes: 5 +# env: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # with: -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} -# SONAR_PROJETCKEY: python-app # GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + #Test Sonar Script + - name: Get Sonar Status and comment PR + if: always() + uses: campos-pay/Sonar-status-check@main + with: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_PROJETCKEY: python-app + GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} From c14b585c982c13396e7d3f830d806aae05bdaf59 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Tue, 13 Sep 2022 21:22:57 -0300 Subject: [PATCH 29/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 35 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index b699cd7..f2e93f7 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -19,21 +19,26 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} -# - name: SonarQube Quality Gate check -# uses: campos-pay/sonarqube-quality-gate-action@master -# id: sonar -# timeout-minutes: 5 -# env: -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: SonarQube Quality Gate check + id: sonarqube-quality-gate-check + uses: sonarsource/sonarqube-quality-gate-action@master + # Force to fail step after specific time. + timeout-minutes: 5 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #OPTIONAL + + # Optionally you can use the output from the Quality Gate in another step. + # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. + - name: "Example show SonarQube Quality Gate Status value" + run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" + #Test Sonar Script +# - name: Get Sonar Status and comment PR +# if: always() +# uses: campos-pay/Sonar-status-check@main # with: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} +# SONAR_PROJETCKEY: python-app # GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} - #Test Sonar Script - - name: Get Sonar Status and comment PR - if: always() - uses: campos-pay/Sonar-status-check@main - with: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_PROJETCKEY: python-app - GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} From 953e8cba291e07a75917d6ddb3088272853388f5 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Tue, 13 Sep 2022 21:26:27 -0300 Subject: [PATCH 30/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index f2e93f7..0e25635 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -31,6 +31,7 @@ jobs: # Optionally you can use the output from the Quality Gate in another step. # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. - name: "Example show SonarQube Quality Gate Status value" + if: always() run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" #Test Sonar Script # - name: Get Sonar Status and comment PR From 1abcaa8475ab0c832892dc77db5027c6c4c8f0a6 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Tue, 13 Sep 2022 21:41:32 -0300 Subject: [PATCH 31/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 0e25635..17bf7af 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -32,7 +32,8 @@ jobs: # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. - name: "Example show SonarQube Quality Gate Status value" if: always() - run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" + run: echo The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }} + shell: bash #Test Sonar Script # - name: Get Sonar Status and comment PR # if: always() From e9a17da746cdb299ad50ea7efb4db1cc0ff98066 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Tue, 13 Sep 2022 21:46:05 -0300 Subject: [PATCH 32/66] Delete testesonar.py --- telegram_bot/networking/testesonar.py | 255 -------------------------- 1 file changed, 255 deletions(-) delete mode 100644 telegram_bot/networking/testesonar.py diff --git a/telegram_bot/networking/testesonar.py b/telegram_bot/networking/testesonar.py deleted file mode 100644 index 942fecd..0000000 --- a/telegram_bot/networking/testesonar.py +++ /dev/null @@ -1,255 +0,0 @@ -# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy()# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() From 035e97cf0f01e2bb316b4e7b544eb918369b9658 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Tue, 13 Sep 2022 21:59:56 -0300 Subject: [PATCH 33/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 17bf7af..7d9afd5 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -21,7 +21,7 @@ jobs: SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - name: SonarQube Quality Gate check id: sonarqube-quality-gate-check - uses: sonarsource/sonarqube-quality-gate-action@master + uses: campos-pay/sonarqube-quality-gate-action@master # Force to fail step after specific time. timeout-minutes: 5 env: From dab2d9e921a0eb69ace9538cb08cb8f9539e6646 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Tue, 13 Sep 2022 22:05:55 -0300 Subject: [PATCH 34/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 7d9afd5..c929063 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -32,8 +32,7 @@ jobs: # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. - name: "Example show SonarQube Quality Gate Status value" if: always() - run: echo The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }} - shell: bash + run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" #Test Sonar Script # - name: Get Sonar Status and comment PR # if: always() From 8e877cf1509c683173298cd41ce9bc7572be255b Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Tue, 13 Sep 2022 22:31:29 -0300 Subject: [PATCH 35/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 45 +++++++++++++++++--------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index c929063..dc6bafe 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -19,27 +19,30 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - - name: SonarQube Quality Gate check - id: sonarqube-quality-gate-check - uses: campos-pay/sonarqube-quality-gate-action@master - # Force to fail step after specific time. - timeout-minutes: 5 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #OPTIONAL +# - name: SonarQube Quality Gate check +# id: sonarqube-quality-gate-check +# uses: campos-pay/sonarqube-quality-gate-action@master +# # Force to fail step after specific time. +# timeout-minutes: 5 +# env: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #OPTIONAL - # Optionally you can use the output from the Quality Gate in another step. - # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. +# # Optionally you can use the output from the Quality Gate in another step. +# # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. +# - name: "Example show SonarQube Quality Gate Status value" +# if: always() +# run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" +# #Test Sonar Script + - name: Get Sonar Status and comment PR + id: test + if: always() + uses: campos-pay/Sonar-status-check@main + with: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_PROJETCKEY: python-app + GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "Example show SonarQube Quality Gate Status value" if: always() - run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" - #Test Sonar Script -# - name: Get Sonar Status and comment PR -# if: always() -# uses: campos-pay/Sonar-status-check@main -# with: -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} -# SONAR_PROJETCKEY: python-app -# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} - + run: echo "The Quality Gate status is ${{ steps.test.outputs.quality_check }}" From 4017c120449604bcad892aab67a2a4aa7c1f4935 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Tue, 13 Sep 2022 22:34:07 -0300 Subject: [PATCH 36/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index dc6bafe..9412f6f 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -35,7 +35,6 @@ jobs: # run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" # #Test Sonar Script - name: Get Sonar Status and comment PR - id: test if: always() uses: campos-pay/Sonar-status-check@main with: @@ -45,4 +44,4 @@ jobs: GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "Example show SonarQube Quality Gate Status value" if: always() - run: echo "The Quality Gate status is ${{ steps.test.outputs.quality_check }}" + run: echo "The Quality Gate status is ${{ steps.check.outputs.quality_check }}" From edf658860002fdcc52656cd34628b59e1e05c1d4 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Tue, 13 Sep 2022 22:48:44 -0300 Subject: [PATCH 37/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 9412f6f..3fe858a 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -19,29 +19,29 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} -# - name: SonarQube Quality Gate check -# id: sonarqube-quality-gate-check -# uses: campos-pay/sonarqube-quality-gate-action@master -# # Force to fail step after specific time. -# timeout-minutes: 5 -# env: -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #OPTIONAL + - name: SonarQube Quality Gate check + id: gate-check + uses: campos-pay/sonarqube-quality-gate-action@master + # Force to fail step after specific time. + timeout-minutes: 5 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #OPTIONAL -# # Optionally you can use the output from the Quality Gate in another step. -# # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. -# - name: "Example show SonarQube Quality Gate Status value" -# if: always() -# run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" -# #Test Sonar Script - - name: Get Sonar Status and comment PR - if: always() - uses: campos-pay/Sonar-status-check@main - with: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_PROJETCKEY: python-app - GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Optionally you can use the output from the Quality Gate in another step. + # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. - name: "Example show SonarQube Quality Gate Status value" if: always() - run: echo "The Quality Gate status is ${{ steps.check.outputs.quality_check }}" + run: echo The Quality Gate status is ${{ steps.gate-check.outputs.quality-gate-status }} + #Test Sonar Script +# - name: Get Sonar Status and comment PR +# if: always() +# uses: campos-pay/Sonar-status-check@main +# with: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} +# SONAR_PROJETCKEY: python-app +# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} +# - name: "Example show SonarQube Quality Gate Status value" +# if: always() +# run: echo The Quality Gate status is ${{ steps.check.outputs.quality_check }} From 9c58004520e55ae7fb31ff54a444a10c2cb1f99a Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Wed, 14 Sep 2022 19:54:25 -0300 Subject: [PATCH 38/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 3fe858a..08c2ac2 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -19,29 +19,29 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - - name: SonarQube Quality Gate check - id: gate-check - uses: campos-pay/sonarqube-quality-gate-action@master - # Force to fail step after specific time. - timeout-minutes: 5 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #OPTIONAL +# - name: SonarQube Quality Gate check +# id: gate-check +# uses: campos-pay/sonarqube-quality-gate-action@master +# # Force to fail step after specific time. +# timeout-minutes: 5 +# env: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #OPTIONAL # Optionally you can use the output from the Quality Gate in another step. # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. - - name: "Example show SonarQube Quality Gate Status value" - if: always() - run: echo The Quality Gate status is ${{ steps.gate-check.outputs.quality-gate-status }} - #Test Sonar Script -# - name: Get Sonar Status and comment PR +# - name: "Example show SonarQube Quality Gate Status value" # if: always() -# uses: campos-pay/Sonar-status-check@main -# with: -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# SONAR_URL: ${{ secrets.SONAR_HOST_URL }} -# SONAR_PROJETCKEY: python-app -# GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} +# run: echo The Quality Gate status is ${{ steps.gate-check.outputs.quality-gate-status }} + #Test Sonar Script + - name: SonarQube Pull Request Comment + uses: campos-pay/sonarqube-pr-comment@v0.1.0 + if: always() + with: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_PROJETCKEY: python-app + GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} # - name: "Example show SonarQube Quality Gate Status value" # if: always() # run: echo The Quality Gate status is ${{ steps.check.outputs.quality_check }} From 25b34d97592c7ddb87fa818682d0ea6523159611 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Wed, 14 Sep 2022 20:26:36 -0300 Subject: [PATCH 39/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 08c2ac2..4168eb8 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -35,11 +35,11 @@ jobs: # run: echo The Quality Gate status is ${{ steps.gate-check.outputs.quality-gate-status }} #Test Sonar Script - name: SonarQube Pull Request Comment - uses: campos-pay/sonarqube-pr-comment@v0.1.0 + uses: campos-pay/sonarqube-pr-comment@main if: always() with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} SONAR_PROJETCKEY: python-app GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} # - name: "Example show SonarQube Quality Gate Status value" From 8089ebb2475307e4ed43235638cd0f008c80c4e4 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 15 Sep 2022 18:19:52 -0300 Subject: [PATCH 40/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 4168eb8..c1b6104 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -19,20 +19,7 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} -# - name: SonarQube Quality Gate check -# id: gate-check -# uses: campos-pay/sonarqube-quality-gate-action@master -# # Force to fail step after specific time. -# timeout-minutes: 5 -# env: -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #OPTIONAL - # Optionally you can use the output from the Quality Gate in another step. - # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. -# - name: "Example show SonarQube Quality Gate Status value" -# if: always() -# run: echo The Quality Gate status is ${{ steps.gate-check.outputs.quality-gate-status }} #Test Sonar Script - name: SonarQube Pull Request Comment uses: campos-pay/sonarqube-pr-comment@main @@ -42,6 +29,3 @@ jobs: SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} SONAR_PROJETCKEY: python-app GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} -# - name: "Example show SonarQube Quality Gate Status value" -# if: always() -# run: echo The Quality Gate status is ${{ steps.check.outputs.quality_check }} From 113f38d38c127ce64c11b7e52b1cbf389aaea947 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 15 Sep 2022 22:36:42 -0300 Subject: [PATCH 41/66] Delete action.yml --- action.yml | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 action.yml diff --git a/action.yml b/action.yml deleted file mode 100644 index 1eb7bf7..0000000 --- a/action.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: "Template for install OpenVPN" - -inputs: - ovpn_config_file: - description: "OVPN Config File" - required: true - ovpn_cert_pass: - description: "OVPN Cert Pass" - required: true -# ovpn_pass: -# description: "OVPN Cert Pass" -# required: true -runs: - using: "composite" - steps: - - name: Installl OpenVPN - shell: bash - run: | - sudo apt-get update > /dev/null - sudo apt-get install openvpn -y > /dev/null - - name: Config VPN - shell: bash - run: | - echo "${{ inputs.ovpn_config_file }}" > cicd.ovpn - echo "${{ inputs.ovpn_cert_pass }}" > vpn_pass.txt - - name: connect on VPN - shell: bash - run: | - sudo openvpn --config cicd.ovpn --askpass vpn_pass.txt --daemon - - name: Waiting VPN connect - shell: bash - run: | - sleep 10 - - name: Checking connection VPN - shell: bash - run: | - found_int_count=$(ip address | grep -o " tun" | wc -l) - if [ $found_int_count -eq 0 ]; then - echo "ERRO: Interface VPN not find!" - else - echo "OK: VPN Interface Found!" - fi From 60097b458eeacef1753d0239f3b2c16b8faa15e3 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Wed, 16 Nov 2022 22:28:51 -0300 Subject: [PATCH 42/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index c1b6104..ac895a2 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -8,7 +8,8 @@ jobs: steps: - uses: actions/checkout@v2 with: - # Disabling shallow clone is recommended for improving relevancy of reporting + # Disabling shallow clone is recommended for improving relevancy of reporting + # fetch-depth: 0 - name: SonarQube Scan uses: sonarsource/sonarqube-scan-action@master From 4c569dc007231b93f70e02ea4ff3e9ec60501263 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Wed, 16 Nov 2022 23:49:05 -0300 Subject: [PATCH 43/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index ac895a2..3c912cd 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -28,5 +28,5 @@ jobs: with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_PROJETCKEY: python-app + SONAR_PROJECTKEY: python-app GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} From 8002a34f99384f20b498a52dcc05a856fb114841 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 01:06:14 -0300 Subject: [PATCH 44/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 3c912cd..db4b2d9 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -23,7 +23,7 @@ jobs: #Test Sonar Script - name: SonarQube Pull Request Comment - uses: campos-pay/sonarqube-pr-comment@main + uses: campos-pay/sonarqube-pr-comment@dev if: always() with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From f0e0d958d401bc034a180001869eed361c30f35e Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 18:21:27 -0300 Subject: [PATCH 45/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index db4b2d9..72d5370 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -6,7 +6,7 @@ jobs: sonarcloud: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: # Disabling shallow clone is recommended for improving relevancy of reporting # From 23bf076414caa6e9e8b046fb95f7d0e52045ec44 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 18:35:25 -0300 Subject: [PATCH 46/66] Create testesonar.py --- telegram_bot/networking/testesonar.py | 255 ++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 telegram_bot/networking/testesonar.py diff --git a/telegram_bot/networking/testesonar.py b/telegram_bot/networking/testesonar.py new file mode 100644 index 0000000..942fecd --- /dev/null +++ b/telegram_bot/networking/testesonar.py @@ -0,0 +1,255 @@ +# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy()# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() From ca1a4942109b18e04ef337e98e9ac9737d8df6aa Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 18:38:53 -0300 Subject: [PATCH 47/66] test sonar --- telegram_bot/networking/vyos.py | 130 ++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/telegram_bot/networking/vyos.py b/telegram_bot/networking/vyos.py index 5c21dbf..4f5c0fa 100644 --- a/telegram_bot/networking/vyos.py +++ b/telegram_bot/networking/vyos.py @@ -126,3 +126,133 @@ def vyos_policy(): print('VyOS') if __name__ == '__main__': vyos_policy() + + #test duplication sonar + + def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() From aa9c6c692352a5dd00fbb1a16e5a86ecd727025a Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 19:08:08 -0300 Subject: [PATCH 48/66] Update vyos.py --- telegram_bot/networking/vyos.py | 216 -------------------------------- 1 file changed, 216 deletions(-) diff --git a/telegram_bot/networking/vyos.py b/telegram_bot/networking/vyos.py index 0d84747..81d5b25 100644 --- a/telegram_bot/networking/vyos.py +++ b/telegram_bot/networking/vyos.py @@ -42,219 +42,3 @@ def vyos_policy(): vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - #test duplication sonar - - def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() From afaab37ff628a849313abddbed98801cfccffabf Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 19:10:24 -0300 Subject: [PATCH 49/66] Delete testesonar.py --- telegram_bot/networking/testesonar.py | 255 -------------------------- 1 file changed, 255 deletions(-) delete mode 100644 telegram_bot/networking/testesonar.py diff --git a/telegram_bot/networking/testesonar.py b/telegram_bot/networking/testesonar.py deleted file mode 100644 index 942fecd..0000000 --- a/telegram_bot/networking/testesonar.py +++ /dev/null @@ -1,255 +0,0 @@ -# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy()# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() From c9d3257ab21406e964c869414c118c2eff5691e7 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 19:33:14 -0300 Subject: [PATCH 50/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 72d5370..c11fdb0 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -23,7 +23,7 @@ jobs: #Test Sonar Script - name: SonarQube Pull Request Comment - uses: campos-pay/sonarqube-pr-comment@dev + uses: campos-pay/sonarqube-pr-comment@main if: always() with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 9eb1eeb9b22edbde9f70a783a5523deaf9328f1f Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 19:39:59 -0300 Subject: [PATCH 51/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index c11fdb0..72d5370 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -23,7 +23,7 @@ jobs: #Test Sonar Script - name: SonarQube Pull Request Comment - uses: campos-pay/sonarqube-pr-comment@main + uses: campos-pay/sonarqube-pr-comment@dev if: always() with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 971aaaeb79aeeccbe3b9b1060337770e957ee4da Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 19:44:22 -0300 Subject: [PATCH 52/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 72d5370..c11fdb0 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -23,7 +23,7 @@ jobs: #Test Sonar Script - name: SonarQube Pull Request Comment - uses: campos-pay/sonarqube-pr-comment@dev + uses: campos-pay/sonarqube-pr-comment@main if: always() with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 141d4806f91273704029fb112c2bb6f325446aff Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 19:46:14 -0300 Subject: [PATCH 53/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index c11fdb0..72d5370 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -23,7 +23,7 @@ jobs: #Test Sonar Script - name: SonarQube Pull Request Comment - uses: campos-pay/sonarqube-pr-comment@main + uses: campos-pay/sonarqube-pr-comment@dev if: always() with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From f8f72ba5d5e6c4332a719f48d509d05a78d5df18 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 19:52:02 -0300 Subject: [PATCH 54/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 72d5370..addf143 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -23,7 +23,7 @@ jobs: #Test Sonar Script - name: SonarQube Pull Request Comment - uses: campos-pay/sonarqube-pr-comment@dev + uses: campos-pay/sonarqube-pr-comment@fix/set-output if: always() with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 6aed652945b8e7b08849c534287463208f2d95c2 Mon Sep 17 00:00:00 2001 From: Guerlielton Date: Thu, 17 Nov 2022 19:58:50 -0300 Subject: [PATCH 55/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index addf143..c11fdb0 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -23,7 +23,7 @@ jobs: #Test Sonar Script - name: SonarQube Pull Request Comment - uses: campos-pay/sonarqube-pr-comment@fix/set-output + uses: campos-pay/sonarqube-pr-comment@main if: always() with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 98329ea9a008eadf00a7c0d329d0ed6f978edd9a Mon Sep 17 00:00:00 2001 From: guerlielton Date: Tue, 16 Jul 2024 22:55:02 +0100 Subject: [PATCH 56/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index c11fdb0..fdc1211 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -6,7 +6,7 @@ jobs: sonarcloud: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: # Disabling shallow clone is recommended for improving relevancy of reporting # From b469258d3a70c2a6a4163ab1b6ebaa7b52f42388 Mon Sep 17 00:00:00 2001 From: guerlielton Date: Tue, 16 Jul 2024 23:28:30 +0100 Subject: [PATCH 57/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index fdc1211..5068af6 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -23,7 +23,7 @@ jobs: #Test Sonar Script - name: SonarQube Pull Request Comment - uses: campos-pay/sonarqube-pr-comment@main + uses: campos-pay/sonarqube-pr-comment@dev if: always() with: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 2265de3cbb495ae21230cf27e196b7c9cffc1ba2 Mon Sep 17 00:00:00 2001 From: guerlielton Date: Tue, 16 Jul 2024 23:35:46 +0100 Subject: [PATCH 58/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 5068af6..8d74db6 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -11,15 +11,15 @@ jobs: # Disabling shallow clone is recommended for improving relevancy of reporting # fetch-depth: 0 - - name: SonarQube Scan - uses: sonarsource/sonarqube-scan-action@master - with: - projectBaseDir: . - args: > - -Dsonar.projectKey=python-app - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + # - name: SonarQube Scan + # uses: sonarsource/sonarqube-scan-action@master + # with: + # projectBaseDir: . + # args: > + # -Dsonar.projectKey=python-app + # env: + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + # SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #Test Sonar Script - name: SonarQube Pull Request Comment From fdc27a173c008aec97c5cc182f877245a3a58623 Mon Sep 17 00:00:00 2001 From: guerlielton Date: Wed, 17 Jul 2024 21:51:35 +0100 Subject: [PATCH 59/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 8d74db6..b1f6a33 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -11,22 +11,24 @@ jobs: # Disabling shallow clone is recommended for improving relevancy of reporting # fetch-depth: 0 - # - name: SonarQube Scan - # uses: sonarsource/sonarqube-scan-action@master - # with: - # projectBaseDir: . - # args: > - # -Dsonar.projectKey=python-app - # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@master + with: + projectBaseDir: . + args: > + -Dsonar.projectKey= ${{ github.repository }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #Test Sonar Script - name: SonarQube Pull Request Comment uses: campos-pay/sonarqube-pr-comment@dev if: always() with: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_PROJECTKEY: python-app - GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + sonar_token: ${{ secrets.SONAR_TOKEN }} + sonar_host_url: ${{ secrets.SONAR_HOST_URL }} + sonar_projectkey: ${{ github.repository }} + github-token: ${{ secrets.GITHUB_TOKEN }} + repo_name: ${{ github.repository }} + pr_number: ${{ github.event.pull_request.number }} From 2bec8309a3b7897609aff3e0f1f06f5d99b95e6e Mon Sep 17 00:00:00 2001 From: guerlielton Date: Wed, 17 Jul 2024 22:00:09 +0100 Subject: [PATCH 60/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index b1f6a33..b22a4b0 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -16,7 +16,7 @@ jobs: with: projectBaseDir: . args: > - -Dsonar.projectKey= ${{ github.repository }} + -Dsonar.projectKey= ${{ github.event.repository.name }} env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} @@ -28,7 +28,7 @@ jobs: with: sonar_token: ${{ secrets.SONAR_TOKEN }} sonar_host_url: ${{ secrets.SONAR_HOST_URL }} - sonar_projectkey: ${{ github.repository }} + sonar_projectkey: ${{ github.event.repository.name }} github-token: ${{ secrets.GITHUB_TOKEN }} repo_name: ${{ github.repository }} pr_number: ${{ github.event.pull_request.number }} From cff0a4033d629d8f9520451e2cce0da21b6eeec6 Mon Sep 17 00:00:00 2001 From: guerlielton Date: Wed, 17 Jul 2024 22:03:23 +0100 Subject: [PATCH 61/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index b22a4b0..360071a 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -16,7 +16,7 @@ jobs: with: projectBaseDir: . args: > - -Dsonar.projectKey= ${{ github.event.repository.name }} + -Dsonar.projectKey=${{ github.event.repository.name }} env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} From 2d44560f301ee21b492bfcfcd1b563a56b2fc411 Mon Sep 17 00:00:00 2001 From: guerlielton Date: Wed, 17 Jul 2024 22:12:19 +0100 Subject: [PATCH 62/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 360071a..6245606 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -11,24 +11,24 @@ jobs: # Disabling shallow clone is recommended for improving relevancy of reporting # fetch-depth: 0 - - name: SonarQube Scan - uses: sonarsource/sonarqube-scan-action@master - with: - projectBaseDir: . - args: > - -Dsonar.projectKey=${{ github.event.repository.name }} - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + # - name: SonarQube Scan + # uses: sonarsource/sonarqube-scan-action@master + # with: + # projectBaseDir: . + # args: > + # -Dsonar.projectKey=${{ github.event.repository.name }} + # env: + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + # SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #Test Sonar Script - name: SonarQube Pull Request Comment uses: campos-pay/sonarqube-pr-comment@dev if: always() with: - sonar_token: ${{ secrets.SONAR_TOKEN }} - sonar_host_url: ${{ secrets.SONAR_HOST_URL }} - sonar_projectkey: ${{ github.event.repository.name }} - github-token: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_PROJECTKEY: ${{ github.event.repository.name }} + GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} repo_name: ${{ github.repository }} pr_number: ${{ github.event.pull_request.number }} From 52a69a2b5fbe8159f6f90dd09e2b1d42a9d9e4ef Mon Sep 17 00:00:00 2001 From: guerlielton Date: Wed, 17 Jul 2024 22:20:57 +0100 Subject: [PATCH 63/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 6245606..e2b8919 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -9,26 +9,25 @@ jobs: - uses: actions/checkout@v4 with: # Disabling shallow clone is recommended for improving relevancy of reporting - # fetch-depth: 0 - # - name: SonarQube Scan - # uses: sonarsource/sonarqube-scan-action@master - # with: - # projectBaseDir: . - # args: > - # -Dsonar.projectKey=${{ github.event.repository.name }} - # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@master + with: + projectBaseDir: . + args: > + -Dsonar.projectKey=${{ github.event.repository.name }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #Test Sonar Script - name: SonarQube Pull Request Comment uses: campos-pay/sonarqube-pr-comment@dev if: always() with: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_PROJECTKEY: ${{ github.event.repository.name }} - GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }} + sonar_token: ${{ secrets.SONAR_TOKEN }} + sonar_host_url: ${{ secrets.SONAR_HOST_URL }} + sonar_projectkey: ${{ github.event.repository.name }} + github-token: ${{ secrets.GITHUB_TOKEN }} repo_name: ${{ github.repository }} pr_number: ${{ github.event.pull_request.number }} From 9c90ad71a38d1e35b06f3eff3c064d7accbb4ba2 Mon Sep 17 00:00:00 2001 From: guerlielton Date: Wed, 17 Jul 2024 22:59:09 +0100 Subject: [PATCH 64/66] Create testesonar.py --- telegram_bot/networking/testesonar.py | 255 ++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 telegram_bot/networking/testesonar.py diff --git a/telegram_bot/networking/testesonar.py b/telegram_bot/networking/testesonar.py new file mode 100644 index 0000000..4bd89ba --- /dev/null +++ b/telegram_bot/networking/testesonar.py @@ -0,0 +1,255 @@ +# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy()# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() + + # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 +def vyos_policy(): + arq = open('VyOS-Policy.txt','w') + count = 0 + file = open('asn-list.txt', 'r') + t = [] + ru = 1 + for line in file.readlines(): + line = line.rstrip() + t.append(line) + for e in range(len(t)): + if 'AS' in t[e]: + ipv6 = [] + ipv4 = [] + k = 1 + while ('/' in t[e+k] ): + if ('::' in t[e+k]): + ipv6.append(e+k) + else: + ipv4.append(e+k) + k = k + 1 + for l in range(len(ipv4)): + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) + print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) + ru = ru + 1 + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) + print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) + # for p in range(len(ipv6)): + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) + # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) + # print('------------------------------------------------------------------------------------------------',file=arq) + count = count + 1 + print() + print('Have been configured',count,'Routing Policy') + print('VyOS') +if __name__ == '__main__': + vyos_policy() From 8d44628f44ede2215c706010188853d0be450f1b Mon Sep 17 00:00:00 2001 From: guerlielton Date: Wed, 17 Jul 2024 23:22:31 +0100 Subject: [PATCH 65/66] Update sonar-scan.yml --- .github/workflows/sonar-scan.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index e2b8919..d7c6b46 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -19,8 +19,10 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - - #Test Sonar Script + + - name: Esperando resultados do SonarQube Quality Gate + run: sleep 15 + - name: SonarQube Pull Request Comment uses: campos-pay/sonarqube-pr-comment@dev if: always() From 33726d8c1bbf828f5af751f7cbf50821af098044 Mon Sep 17 00:00:00 2001 From: guerlielton Date: Wed, 17 Jul 2024 23:27:58 +0100 Subject: [PATCH 66/66] Delete telegram_bot/networking/testesonar.py --- telegram_bot/networking/testesonar.py | 255 -------------------------- 1 file changed, 255 deletions(-) delete mode 100644 telegram_bot/networking/testesonar.py diff --git a/telegram_bot/networking/testesonar.py b/telegram_bot/networking/testesonar.py deleted file mode 100644 index 4bd89ba..0000000 --- a/telegram_bot/networking/testesonar.py +++ /dev/null @@ -1,255 +0,0 @@ -# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy()# Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy() - - # Using F string and increment numbers in Cisco router-map and Huawei router-policy init in 100 increments 10 -def vyos_policy(): - arq = open('VyOS-Policy.txt','w') - count = 0 - file = open('asn-list.txt', 'r') - t = [] - ru = 1 - for line in file.readlines(): - line = line.rstrip() - t.append(line) - for e in range(len(t)): - if 'AS' in t[e]: - ipv6 = [] - ipv4 = [] - k = 1 - while ('/' in t[e+k] ): - if ('::' in t[e+k]): - ipv6.append(e+k) - else: - ipv4.append(e+k) - k = k + 1 - for l in range(len(ipv4)): - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} action permit',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} le 24',file=arq) - print(f'set policy prefix-list ALLOW-PREFIXES-AS-123 rule {ru} prefix {t[ipv4[l]]}\n',file=arq) - ru = ru + 1 - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 action permit',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 10 match ip address prefix-list ALLOW-PREFIXES',file=arq) - print(f'set policy route-map eBGP-DOWNSTREAM-AS-1234-SPO-IN rule 20 action deny',file=arq) - # for p in range(len(ipv6)): - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 from route-filter {t[ipv6[p]]} upto /48',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then local-preference 700',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community set COSTOMER-ISP',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then community add EXPORT-ONLY-ISP2',file=arq) - # print(f'set policy prefix-list eBGP-DOWNSTREAM-ASN-1234-SPO-IN {t[i]}-V6 then accept \n',file=arq) - # print('------------------------------------------------------------------------------------------------',file=arq) - count = count + 1 - print() - print('Have been configured',count,'Routing Policy') - print('VyOS') -if __name__ == '__main__': - vyos_policy()