diff --git a/.github/workflows/ci-dotnet.yaml b/.github/workflows/ci-dotnet.yaml index abf4d346..ccdd822a 100644 --- a/.github/workflows/ci-dotnet.yaml +++ b/.github/workflows/ci-dotnet.yaml @@ -15,6 +15,20 @@ on: - "dotnet/**" - ".github/workflows/ci-dotnet.yaml" workflow_dispatch: + inputs: + environment: + type: choice + description: "Test environment" + options: + - production + - staging + default: "production" + +env: + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/cs')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }} + VAAS_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/cs')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }} + TOKEN_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/cs')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }} jobs: build-dotnet: @@ -52,37 +66,16 @@ jobs: working-directory: dotnet/Vaas - name: Test - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/cs') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - VAAS_URL: "wss://gateway.production.vaas.gdatasecurity.de" - TOKEN_URL: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" - run: dotnet test --no-restore --verbosity normal - working-directory: dotnet/Vaas - - - name: Test staging - if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/cs') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.STAGING_CLIENT_SECRET }} - VAAS_URL: "wss://gateway.staging.vaas.gdatasecurity.de" - TOKEN_URL: "https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token" run: dotnet test --no-restore --verbosity normal working-directory: dotnet/Vaas - name: Run example FileScan env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} SCAN_PATH: "Program.cs" run: dotnet run FileScan working-directory: dotnet/examples/VaasExample - name: Run example UrlScan - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} run: dotnet run UrlScan working-directory: dotnet/examples/VaasExample diff --git a/.github/workflows/ci-golang.yaml b/.github/workflows/ci-golang.yaml index 3a7f39ff..4bb46e45 100644 --- a/.github/workflows/ci-golang.yaml +++ b/.github/workflows/ci-golang.yaml @@ -15,6 +15,20 @@ on: - "golang/vaas/**" - ".github/workflows/ci-golang.yaml" workflow_dispatch: + inputs: + environment: + type: choice + description: "Test environment" + options: + - production + - staging + default: "production" + +env: + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/go')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }} + VAAS_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/go')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }} + TOKEN_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/go')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }} jobs: build-golang: @@ -27,22 +41,7 @@ jobs: go-version: 1.20.5 cache: true cache-dependency-path: golang/vaas/go.sum - - name: run tests staging - if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/go') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.STAGING_CLIENT_SECRET }} - VAAS_URL: "wss://gateway.staging.vaas.gdatasecurity.de" - TOKEN_URL: "https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token" - run: go test ./... - working-directory: golang/vaas/ - name: run tests - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/go') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - VAAS_URL: "wss://gateway.production.vaas.gdatasecurity.de" - TOKEN_URL: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" run: go test ./... working-directory: golang/vaas/ - name: publish module diff --git a/.github/workflows/ci-java-legacy.yaml b/.github/workflows/ci-java-legacy.yaml index 1e65c4aa..bcb23f83 100644 --- a/.github/workflows/ci-java-legacy.yaml +++ b/.github/workflows/ci-java-legacy.yaml @@ -15,6 +15,20 @@ on: - "java/**" - ".github/workflows/ci-java-legacy.yaml" workflow_dispatch: + inputs: + environment: + type: choice + description: "Test environment" + options: + - production + - staging + default: "production" + +env: + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }} + VAAS_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }} + TOKEN_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }} jobs: build-java-legacy: @@ -37,25 +51,6 @@ jobs: gradle-version: "8.1" - name: run tests - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - VAAS_URL: "wss://gateway.production.vaas.gdatasecurity.de" - TOKEN_URL: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" - uses: gradle/gradle-build-action@v2 - with: - arguments: test - gradle-version: "8.1" - build-root-directory: java - - - name: run tests staging - if: github.ref != 'refs/heads/main' && ! startsWith(github.ref, 'refs/tags/java') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.STAGING_CLIENT_SECRET }} - VAAS_URL: "wss://gateway.staging.vaas.gdatasecurity.de" - TOKEN_URL: "https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token" uses: gradle/gradle-build-action@v2 with: arguments: test @@ -64,8 +59,6 @@ jobs: #- name: run examples for file # env: - # CLIENT_ID: ${{ secrets.CLIENT_ID }} - # CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} # SCAN_PATH: "src/main/java/de/gdata/vaasexample/Main.java" # uses: gradle/gradle-build-action@v2 # with: @@ -74,9 +67,6 @@ jobs: # build-root-directory: java/examples/VaasExample #- name: run examples for url - # env: - # CLIENT_ID: ${{ secrets.CLIENT_ID }} - # CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} # uses: gradle/gradle-build-action@v2 # with: # arguments: urlScan diff --git a/.github/workflows/ci-java.yaml b/.github/workflows/ci-java.yaml index f0ceb8cc..ba871452 100644 --- a/.github/workflows/ci-java.yaml +++ b/.github/workflows/ci-java.yaml @@ -15,6 +15,20 @@ on: - "java/**" - ".github/workflows/ci-java.yaml" workflow_dispatch: + inputs: + environment: + type: choice + description: "Test environment" + options: + - production + - staging + default: "production" + +env: + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }} + VAAS_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }} + TOKEN_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }} jobs: build-java: @@ -37,25 +51,6 @@ jobs: gradle-version: "8.1" - name: run tests - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - VAAS_URL: "wss://gateway.production.vaas.gdatasecurity.de" - TOKEN_URL: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" - uses: gradle/gradle-build-action@v2 - with: - arguments: test - gradle-version: "8.1" - build-root-directory: java - - - name: run tests staging - if: github.ref != 'refs/heads/main' && ! startsWith(github.ref, 'refs/tags/java') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.STAGING_CLIENT_SECRET }} - VAAS_URL: "wss://gateway.staging.vaas.gdatasecurity.de" - TOKEN_URL: "https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token" uses: gradle/gradle-build-action@v2 with: arguments: test @@ -64,8 +59,6 @@ jobs: - name: run examples for file env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} SCAN_PATH: "src/main/java/de/gdata/vaasexample/Main.java" uses: gradle/gradle-build-action@v2 with: @@ -74,9 +67,6 @@ jobs: build-root-directory: java/examples/VaasExample - name: run examples for url - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} uses: gradle/gradle-build-action@v2 with: arguments: urlScan diff --git a/.github/workflows/ci-php.yaml b/.github/workflows/ci-php.yaml index a641aa54..beb06b4e 100644 --- a/.github/workflows/ci-php.yaml +++ b/.github/workflows/ci-php.yaml @@ -15,6 +15,20 @@ on: - "php/**" - ".github/workflows/ci-php.yaml" workflow_dispatch: + inputs: + environment: + type: choice + description: "Test environment" + options: + - production + - staging + default: "production" + +env: + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/php')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }} + VAAS_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/php')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }} + TOKEN_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/php')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }} jobs: build-php: @@ -39,22 +53,6 @@ jobs: php_version: ${{ matrix.version }} - name: run tests - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/php') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - VAAS_URL: "wss://gateway.production.vaas.gdatasecurity.de" - TOKEN_URL: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" - run: ./vendor/bin/phpunit --colors --testdox - working-directory: php/tests/vaas - - - name: run tests staging - if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/php') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.STAGING_CLIENT_SECRET }} - VAAS_URL: "wss://gateway.staging.vaas.gdatasecurity.de" - TOKEN_URL: "https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token" run: ./vendor/bin/phpunit --colors --testdox working-directory: php/tests/vaas @@ -64,23 +62,15 @@ jobs: - name: run example (scan file) env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} SCAN_PATH: "GetVerdictByFile.php" run: php GetVerdictByFile.php working-directory: php/examples/VaasExample - name: run example (scan url) - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} run: php GetVerdictByUrl.php working-directory: php/examples/VaasExample - name: run example (scan hash) - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} run: php GetVerdictByHash.php working-directory: php/examples/VaasExample diff --git a/.github/workflows/ci-python.yaml b/.github/workflows/ci-python.yaml index f2828f0c..852e568b 100644 --- a/.github/workflows/ci-python.yaml +++ b/.github/workflows/ci-python.yaml @@ -15,6 +15,20 @@ on: - "python/**" - ".github/workflows/ci-python.yaml" workflow_dispatch: + inputs: + environment: + type: choice + description: "Test environment" + options: + - production + - staging + default: "production" + +env: + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/py')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }} + VAAS_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/py')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }} + TOKEN_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/py')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }} jobs: build-python: @@ -34,22 +48,6 @@ jobs: working-directory: python - name: run tests - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/py') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - VAAS_URL: "wss://gateway.production.vaas.gdatasecurity.de" - TOKEN_URL: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" - run: python -m unittest -v tests/test_* - working-directory: python - - - name: run tests staging - if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/py') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.STAGING_CLIENT_SECRET }} - VAAS_URL: "wss://gateway.staging.vaas.gdatasecurity.de" - TOKEN_URL: "https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token" run: python -m unittest -v tests/test_* working-directory: python @@ -59,16 +57,11 @@ jobs: - name: run example scan file env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} SCAN_PATH: "main.py" run: python main.py working-directory: python/examples/VaasExample - name: run example scan url - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} run: python main_url.py working-directory: python/examples/VaasExample diff --git a/.github/workflows/ci-ruby.yaml b/.github/workflows/ci-ruby.yaml index 20c2ebda..f4a1788f 100644 --- a/.github/workflows/ci-ruby.yaml +++ b/.github/workflows/ci-ruby.yaml @@ -15,6 +15,20 @@ on: - "ruby/**" - ".github/workflows/ci-ruby.yaml" workflow_dispatch: + inputs: + environment: + type: choice + description: "Test environment" + options: + - production + - staging + default: "production" + +env: + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rb')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }} + VAAS_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rb')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }} + TOKEN_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rb')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }} jobs: build-ruby: @@ -56,38 +70,18 @@ jobs: working-directory: ruby - name: Test - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rb') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - VAAS_URL: "wss://gateway.production.vaas.gdatasecurity.de" - TOKEN_URL: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" - run: ruby vaas_test.rb - working-directory: ruby/test - - - name: Test staging - if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/rb') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.STAGING_CLIENT_SECRET }} - VAAS_URL: "wss://gateway.staging.vaas.gdatasecurity.de" - TOKEN_URL: "https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token" run: ruby vaas_test.rb working-directory: ruby/test - name: Run simple example env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - URL: "https://www.gdata.de/" + URL: "https://github.com/GDATASoftwareAG/vaas" run: ruby simple_example.rb working-directory: ruby/examples - name: Run example with reconnect env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - URL: "https://www.gdata.de/" + URL: "https://github.com/GDATASoftwareAG/vaas" run: ruby example_with_reconnect.rb working-directory: ruby/examples diff --git a/.github/workflows/ci-rust.yaml b/.github/workflows/ci-rust.yaml index 03d1bf11..5e3bcc9e 100644 --- a/.github/workflows/ci-rust.yaml +++ b/.github/workflows/ci-rust.yaml @@ -15,6 +15,20 @@ on: - "rust/**" - ".github/workflows/ci-rust.yaml" workflow_dispatch: + inputs: + environment: + type: choice + description: "Test environment" + options: + - production + - staging + default: "production" + +env: + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rs')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }} + VAAS_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rs')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }} + TOKEN_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rs')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }} jobs: build-rust: @@ -35,22 +49,6 @@ jobs: working-directory: rust - name: run tests - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rs') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - VAAS_URL: "wss://gateway.production.vaas.gdatasecurity.de" - TOKEN_URL: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" - run: cargo test - working-directory: rust - - - name: run tests staging - if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/rs') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.STAGING_CLIENT_SECRET }} - VAAS_URL: "wss://gateway.staging.vaas.gdatasecurity.de" - TOKEN_URL: "https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token" run: cargo test working-directory: rust diff --git a/.github/workflows/ci-typescript.yaml b/.github/workflows/ci-typescript.yaml index e6c4b9a8..22b76229 100644 --- a/.github/workflows/ci-typescript.yaml +++ b/.github/workflows/ci-typescript.yaml @@ -15,6 +15,20 @@ on: - "typescript/**" - ".github/workflows/ci-typescript.yaml" workflow_dispatch: + inputs: + environment: + type: choice + description: "Test environment" + options: + - production + - staging + default: "production" + +env: + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/ts')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }} + VAAS_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/ts')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }} + TOKEN_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/ts')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }} jobs: build-typescript: @@ -49,22 +63,6 @@ jobs: working-directory: typescript - name: run tests - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/ts') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - VAAS_URL: "wss://gateway.production.vaas.gdatasecurity.de" - TOKEN_URL: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" - run: pnpm run test - working-directory: typescript - - - name: run tests staging - if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/ts') - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.STAGING_CLIENT_SECRET }} - VAAS_URL: "wss://gateway.staging.vaas.gdatasecurity.de" - TOKEN_URL: "https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token" run: pnpm run test working-directory: typescript @@ -74,16 +72,11 @@ jobs: - name: run examples scan file env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} SCAN_PATH: "main.ts" run: npx ts-node main.ts working-directory: typescript/examples/VaasExample - name: run examples scan url - env: - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} run: npx ts-node url_scan.ts working-directory: typescript/examples/VaasExample diff --git a/dotnet/Vaas/test/Vaas.Test/IntegrationTests.cs b/dotnet/Vaas/test/Vaas.Test/IntegrationTests.cs index aaa04e35..0fa40a58 100644 --- a/dotnet/Vaas/test/Vaas.Test/IntegrationTests.cs +++ b/dotnet/Vaas/test/Vaas.Test/IntegrationTests.cs @@ -159,8 +159,8 @@ public async Task FromUrlReturnVerdict(string url, Verdict verdict) public async Task ForUrl_WithUrlWithStatusCode4xx_ThrowsVaasClientException() { var vaas = await AuthenticateWithCredentials(); - var e = await Assert.ThrowsAsync(() => vaas.ForUrlAsync(new Uri("https://www.gdata.de/nocontenthere"))); - Assert.Equal("Call failed with status code 404 (Not Found): GET https://www.gdata.de/nocontenthere", e.Message); + var e = await Assert.ThrowsAsync(() => vaas.ForUrlAsync(new Uri("https://upload.production.vaas.gdatasecurity.de/nocontenthere"))); + Assert.Equal("Call failed with status code 404 (Not Found): GET https://upload.production.vaas.gdatasecurity.de/nocontenthere", e.Message); } private static async Task AuthenticateWithCredentials() @@ -191,4 +191,4 @@ public async Task UploadEmptyFile() Assert.Equal(Verdict.Clean, result.Verdict); Assert.Equal(Vaas.Sha256CheckSum("empty.txt"), result.Sha256); } -} \ No newline at end of file +} diff --git a/dotnet/examples/VaasExample/Program.cs b/dotnet/examples/VaasExample/Program.cs index 33490fad..c01898d2 100644 --- a/dotnet/examples/VaasExample/Program.cs +++ b/dotnet/examples/VaasExample/Program.cs @@ -15,12 +15,14 @@ public static async Task Main(string[] args) private static async Task FileScan() { - var vaas = new Vaas.Vaas(); - vaas.Url = new Uri("wss://gateway.production.vaas.gdatasecurity.de"); + var vaas = new Vaas.Vaas() + { + Url = new Uri(Environment.GetEnvironmentVariable("VAAS_URL") ?? "wss://gateway.production.vaas.gdatasecurity.de"), + }; var authenticator = new ClientCredentialsGrantAuthenticator( Environment.GetEnvironmentVariable("CLIENT_ID") ?? string.Empty, Environment.GetEnvironmentVariable("CLIENT_SECRET") ?? string.Empty, - new Uri("https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token") + new Uri(Environment.GetEnvironmentVariable("TOKEN_URL") ?? "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token") ); await vaas.Connect(await authenticator.GetToken()); @@ -32,12 +34,14 @@ private static async Task FileScan() private static async Task UrlScan() { - var vaas = new Vaas.Vaas(); - vaas.Url = new Uri("wss://gateway.production.vaas.gdatasecurity.de"); + var vaas = new Vaas.Vaas() + { + Url = new Uri(Environment.GetEnvironmentVariable("VAAS_URL") ?? "wss://gateway.production.vaas.gdatasecurity.de"), + }; var authenticator = new ClientCredentialsGrantAuthenticator( Environment.GetEnvironmentVariable("CLIENT_ID") ?? string.Empty, Environment.GetEnvironmentVariable("CLIENT_SECRET") ?? string.Empty, - new Uri("https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token") + new Uri(Environment.GetEnvironmentVariable("TOKEN_URL") ?? "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token") ); await vaas.Connect(await authenticator.GetToken()); diff --git a/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Main.java b/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Main.java index 4f3dab6e..aa50076e 100644 --- a/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Main.java +++ b/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Main.java @@ -13,11 +13,18 @@ public static void main(String[] args) throws Exception { var clientId = System.getenv("CLIENT_ID"); var clientSecret = System.getenv("CLIENT_SECRET"); var scanPath = System.getenv("SCAN_PATH"); + var tokenUrl = System.getenv("TOKEN_URL"); + if (tokenUrl == null) { + tokenUrl = "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"; + } + var vaasUrl = System.getenv("VAAS_URL"); + if (vaasUrl == null) { + vaasUrl = "wss://gateway.production.vaas.gdatasecurity.de"; + } - var authenticator = new ClientCredentialsGrantAuthenticator(clientId, clientSecret, - "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"); + var authenticator = new ClientCredentialsGrantAuthenticator(clientId, clientSecret, tokenUrl); var config = new VaasConfig( - new URI("wss://gateway.production.vaas.gdatasecurity.de")); + new URI(vaasUrl)); var vaas = new Vaas(config, authenticator); vaas.connect(); diff --git a/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/UrlScan.java b/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/UrlScan.java index bebd46ff..39ce78e9 100644 --- a/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/UrlScan.java +++ b/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/UrlScan.java @@ -12,11 +12,17 @@ public class UrlScan { public static void main(String[] args) throws Exception { var clientId = System.getenv("CLIENT_ID"); var clientSecret = System.getenv("CLIENT_SECRET"); + var tokenUrl = System.getenv("TOKEN_URL"); + if (tokenUrl == null) { + tokenUrl = "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"; + } + var vaasUrl = System.getenv("VAAS_URL"); + if (vaasUrl == null) { + vaasUrl = "wss://gateway.production.vaas.gdatasecurity.de"; + } - var authenticator = new ClientCredentialsGrantAuthenticator(clientId, clientSecret, - "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"); - var config = new VaasConfig( - new URI("wss://gateway.production.vaas.gdatasecurity.de")); + var authenticator = new ClientCredentialsGrantAuthenticator(clientId, clientSecret, tokenUrl); + var config = new VaasConfig(new URI(vaasUrl)); var vaas = new Vaas(config, authenticator); vaas.connect(); diff --git a/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java b/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java index 3ae38fae..88cce96d 100644 --- a/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java +++ b/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java @@ -345,15 +345,15 @@ public void forUrl_WithUrlNull_ThrowsNullPointerException() throws Exception { @Test public void forUrl_WithUrlWithStatusCode4xx_ThrowsVaasClientException() throws Exception { var vaas = this.getVaasWithCredentials(); - var url_1 = new URL("https://gdata.de/nocontenthere"); + var url_1 = new URL("https://upload.production.vaas.gdatasecurity.de/nocontenthere"); var e = assertThrows(VaasClientException.class, () -> vaas.forUrl(url_1)); - assertEquals("Call failed with status code 404 (Not Found): GET https://gdata.de/nocontenthere", e.getMessage()); + assertEquals("Call failed with status code 404 (Not Found): GET https://upload.production.vaas.gdatasecurity.de/nocontenthere", e.getMessage()); } @Test @Disabled("Used for manual testing") public void fromUrlInALoop() throws Exception { - var url_1 = new URL("https://www.gdata.de/robots.txt"); + var url_1 = new URL("https://github.com/GDATASoftwareAG/vaas"); while (true) { try { @@ -378,9 +378,9 @@ public void fromUrlInALoop() throws Exception { @Test public void fromUrlMultipleCleanUrls() throws Exception { var vaas = this.getVaasWithCredentials(); - var url_1 = new URL("https://www.gdata.de/robots.txt"); - var url_2 = new URL("https://www.gdata.de/robots.txt"); - var url_3 = new URL("https://www.gdata.de/robots.txt"); + var url_1 = new URL("https://github.com/GDATASoftwareAG/vaas"); + var url_2 = new URL("https://github.com/GDATASoftwareAG/vaas"); + var url_3 = new URL("https://github.com/GDATASoftwareAG/vaas"); var verdictRequestAttributes = new VerdictRequestAttributes(); verdictRequestAttributes.setTenantId("GiveMeThatHashes"); @@ -444,4 +444,4 @@ private Vaas getVaasWithCredentials() return client; } -} \ No newline at end of file +} diff --git a/php/examples/VaasExample/GetVerdictByFile.php b/php/examples/VaasExample/GetVerdictByFile.php index c91fa4c1..9e9759fa 100644 --- a/php/examples/VaasExample/GetVerdictByFile.php +++ b/php/examples/VaasExample/GetVerdictByFile.php @@ -11,11 +11,11 @@ $authenticator = new ClientCredentialsGrantAuthenticator( getenv("CLIENT_ID"), getenv("CLIENT_SECRET"), - "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" + getenv("TOKEN_URL") ?? "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" ); $vaas = new Vaas( - "wss://gateway.production.vaas.gdatasecurity.de" + getenv("VAAS_URL") ?? "wss://gateway.production.vaas.gdatasecurity.de" ); $vaas->Connect($authenticator->getToken()); diff --git a/php/examples/VaasExample/GetVerdictByHash.php b/php/examples/VaasExample/GetVerdictByHash.php index 3cca519c..1ae4e432 100644 --- a/php/examples/VaasExample/GetVerdictByHash.php +++ b/php/examples/VaasExample/GetVerdictByHash.php @@ -10,10 +10,9 @@ $authenticator = new ClientCredentialsGrantAuthenticator( getenv("CLIENT_ID"), getenv("CLIENT_SECRET"), - "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" -); + getenv("TOKEN_URL") ?? "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"); $vaas = new Vaas( - "wss://gateway.production.vaas.gdatasecurity.de" + getenv("VAAS_URL") ?? "wss://gateway.production.vaas.gdatasecurity.de" ); $vaas->Connect($authenticator->getToken()); diff --git a/php/examples/VaasExample/GetVerdictByUrl.php b/php/examples/VaasExample/GetVerdictByUrl.php index 9b8b2b5e..ba7c6eda 100644 --- a/php/examples/VaasExample/GetVerdictByUrl.php +++ b/php/examples/VaasExample/GetVerdictByUrl.php @@ -10,10 +10,9 @@ $authenticator = new ClientCredentialsGrantAuthenticator( getenv("CLIENT_ID"), getenv("CLIENT_SECRET"), - "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" -); + getenv("TOKEN_URL") ?? "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"); $vaas = new Vaas( - "wss://gateway.production.vaas.gdatasecurity.de" + getenv("VAAS_URL") ?? "wss://gateway.production.vaas.gdatasecurity.de" ); $vaas->Connect($authenticator->getToken()); diff --git a/php/tests/vaas/VaasTest.php b/php/tests/vaas/VaasTest.php index b391ea74..e3c76c06 100644 --- a/php/tests/vaas/VaasTest.php +++ b/php/tests/vaas/VaasTest.php @@ -381,10 +381,10 @@ public function testForUrl_WithNull_ThrowsVaasClientException() { public function testForUrl_WithStatus4xx_ThrowsVaasClientException() { $vaas = new Vaas($_ENV["VAAS_URL"], $this->_getDebugLogger()); $this->expectException(VaasClientException::class); - $this->expectExceptionMessage("Call failed with status code 404 (Not Found): GET https://www.gdata.de/nocontentthere"); + $this->expectExceptionMessage("Call failed with status code 404 (Not Found): GET https://upload.production.vaas.gdatasecurity.de/nocontenthere"); $vaas->Connect($this->getClientCredentialsGrantAuthenticator()->getToken()); - $invalidUrl = "https://www.gdata.de/nocontentthere"; + $invalidUrl = "https://upload.production.vaas.gdatasecurity.de/nocontenthere"; $verdict = $vaas->ForUrl($invalidUrl); $this->_getDebugLogger()->info("Verdict for URL " . $invalidUrl . " is " . $verdict->Verdict); } diff --git a/python/examples/VaasExample/main.py b/python/examples/VaasExample/main.py index 68afe5f2..ff8aa6b2 100644 --- a/python/examples/VaasExample/main.py +++ b/python/examples/VaasExample/main.py @@ -5,12 +5,20 @@ async def main(): + token_url = os.getenv("TOKEN_URL") + vaas_url = os.getenv("VAAS_URL") + + if token_url is None: + token_url = "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" + if vaas_url is None: + vaas_url = "wss://gateway.production.vaas.gdatasecurity.de" + authenticator = ClientCredentialsGrantAuthenticator( os.getenv("CLIENT_ID"), os.getenv("CLIENT_SECRET"), - "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" + token_endpoint=token_url ) - async with Vaas(url="wss://gateway.production.vaas.gdatasecurity.de") as vaas: + async with Vaas(url=vaas_url) as vaas: token = await authenticator.get_token() await vaas.connect(token) path = os.getenv("SCAN_PATH") diff --git a/python/examples/VaasExample/main_url.py b/python/examples/VaasExample/main_url.py index b8d078bf..3f978290 100644 --- a/python/examples/VaasExample/main_url.py +++ b/python/examples/VaasExample/main_url.py @@ -4,12 +4,20 @@ async def main(): + token_url = os.getenv("TOKEN_URL") + vaas_url = os.getenv("VAAS_URL") + + if token_url is None: + token_url = "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" + if vaas_url is None: + vaas_url = "wss://gateway.production.vaas.gdatasecurity.de" + authenticator = ClientCredentialsGrantAuthenticator( os.getenv("CLIENT_ID"), os.getenv("CLIENT_SECRET"), - "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" + token_endpoint=token_url ) - async with Vaas(url="wss://gateway.production.vaas.gdatasecurity.de") as vaas: + async with Vaas(url=vaas_url) as vaas: await vaas.connect(await authenticator.get_token()) url = "https://secure.eicar.org/eicar.com" verdict = await vaas.for_url(url) diff --git a/ruby/examples/example_with_reconnect.rb b/ruby/examples/example_with_reconnect.rb index f16a2cad..fddd2b2e 100644 --- a/ruby/examples/example_with_reconnect.rb +++ b/ruby/examples/example_with_reconnect.rb @@ -4,17 +4,20 @@ CLIENT_ID = ENV.fetch('CLIENT_ID') CLIENT_SECRET = ENV.fetch('CLIENT_SECRET') +VAAS_URL = ENV.fetch('VAAS_URL', "wss://gateway.production.vaas.gdatasecurity.de") +TOKEN_URL = ENV.fetch('TOKEN_URL', 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token') + URL = ENV.fetch('URL') def main authenticator = VAAS::ClientCredentialsGrantAuthenticator.new( CLIENT_ID, CLIENT_SECRET, - "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" + TOKEN_URL ) # create a vaas object and get a token to authenticate - vaas = VAAS::VaasMain.new + vaas = VAAS::VaasMain.new(VAAS_URL) token = authenticator.get_token Async do diff --git a/ruby/examples/simple_example.rb b/ruby/examples/simple_example.rb index 958e7955..2af1e96d 100644 --- a/ruby/examples/simple_example.rb +++ b/ruby/examples/simple_example.rb @@ -4,17 +4,20 @@ CLIENT_ID = ENV.fetch('CLIENT_ID') CLIENT_SECRET = ENV.fetch('CLIENT_SECRET') +VAAS_URL = ENV.fetch('VAAS_URL', "wss://gateway.production.vaas.gdatasecurity.de") +TOKEN_URL = ENV.fetch('TOKEN_URL', 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token') + URL = ENV.fetch('URL') def main authenticator = VAAS::ClientCredentialsGrantAuthenticator.new( CLIENT_ID, CLIENT_SECRET, - "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" + TOKEN_URL ) # create a vaas object and get a token to authenticate - vaas = VAAS::VaasMain.new + vaas = VAAS::VaasMain.new(VAAS_URL) token = authenticator.get_token Async do