Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,50 +286,6 @@ jobs:
--type=coverage-metrics


snyk-container-scan:
runs-on: ubuntu-latest
needs: [build-image]
env:
IMAGE_NAME: ${{ needs.build-image.outputs.tagged_image_name }}
KOSLI_FINGERPRINT: ${{ needs.build-image.outputs.digest }}
SARIF_FILENAME: snyk.container.scan.json
steps:
- name: Download docker image
uses: cyber-dojo/download-artifact@main
with:
image_digest: ${{ needs.build-image.outputs.digest }}

- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Setup Snyk
uses: snyk/actions/setup@master

- name: Run Snyk container scan
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
run:
snyk container test ${IMAGE_NAME}
--policy-path=.snyk
--sarif
--sarif-file-output="${SARIF_FILENAME}"

- name: Setup Kosli CLI
if: ${{ github.ref == 'refs/heads/main' && (success() || failure()) }}
uses: kosli-dev/setup-cli-action@v2
with:
version: ${{ vars.KOSLI_CLI_VERSION }}

- name: Attest evidence to Kosli
if: ${{ github.ref == 'refs/heads/main' && (success() || failure()) }}
run:
kosli attest snyk
--attachments=.snyk
--name=differ.snyk-container-scan
--scan-results="${SARIF_FILENAME}"


sonarcloud-scan:
runs-on: ubuntu-latest
needs: [build-image]
Expand Down Expand Up @@ -361,7 +317,6 @@ jobs:
- rubocop-lint
- unit-tests
- integration-tests
- snyk-container-scan
- snyk-code-scan
- sonarcloud-scan
env:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

## main.yml
main.yml runs when there is a pushed commit.
Reports to https://app.kosli.com
The workflow to look in if you want to learn about [Kosli](https://kosli.com).
The main structure in this workflow is:
- The build-image job calls a [reusable-workflow](https://github.com/cyber-dojo/reusable-actions-workflows) which:
- builds the image
Expand All @@ -16,6 +14,9 @@ The main structure in this workflow is:
- They load it from the Github Action cache using [cyber-dojo/download-artifact@main](https://github.com/cyber-dojo/download-artifact)
- The kosli-attest commands use the fingerprint returned from the build-image job

Reports compliance to https://app.kosli.com
The workflow to look in if you want to learn about [Kosli](https://app.kosli.com/cyber-dojo/flows/differ-ci/trails/).


## deploy-manually-to-aws-beta.yml
Deliberately run a non-compliant (but functional) artifact to https://beta.cyber-dojo.org for Kosli demo purposes.
Expand Down
2 changes: 0 additions & 2 deletions .kosli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ trail:
attestations:
- name: rubocop-lint
type: junit
- name: snyk-container-scan
type: snyk
- name: snyk-code-scan
type: snyk
- name: unit-test
Expand Down
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ Style/FetchEnvVar:
Exclude:
- source/server/app_base.rb

Style/FrozenStringLiteralComment:
Exclude:
- source/**/*

Style/HashConversion:
Exclude:
- source/server/app_base.rb
Expand Down
2 changes: 0 additions & 2 deletions source/client/client.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'http_json_args'
require 'json'
require 'rack'
Expand Down
2 changes: 0 additions & 2 deletions source/client/config/config.ru
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

$stdout.sync = true
$stderr.sync = true

Expand Down
1 change: 0 additions & 1 deletion source/client/config/puma.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env puma
# frozen_string_literal: true

environment('production')
rackup("#{__dir__}/config.ru")
5 changes: 3 additions & 2 deletions source/client/config/up.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash -Eeu
#!/usr/bin/env bash
set -Eeu

readonly PORT="${CYBER_DOJO_DIFFER_CLIENT_PORT}"
readonly MY_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

export RUBYOPT='-W2'
export RUBYOPT='-W2 --enable-frozen-string-literal'

puma \
--port=${PORT} \
Expand Down
2 changes: 0 additions & 2 deletions source/client/differ.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'http_json_hash/service'

module External
Expand Down
2 changes: 0 additions & 2 deletions source/client/html_demo.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'differ'

class HtmlDemo
Expand Down
2 changes: 0 additions & 2 deletions source/client/http_json_args.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class HttpJsonArgs
def get(path)
case path
Expand Down
2 changes: 0 additions & 2 deletions source/client/http_json_hash/http.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require 'net/http'

module HttpJsonHash
Expand Down
2 changes: 0 additions & 2 deletions source/client/http_json_hash/requester.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'http'
require 'json'
require 'uri'
Expand Down
2 changes: 0 additions & 2 deletions source/client/http_json_hash/service.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'requester'
require_relative 'unpacker'

Expand Down
2 changes: 0 additions & 2 deletions source/client/http_json_hash/service_error.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require 'json'

module HttpJsonHash
Expand Down
2 changes: 0 additions & 2 deletions source/client/http_json_hash/unpacker.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'service_error'
require 'json'

Expand Down
2 changes: 0 additions & 2 deletions source/client/saver.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'http_json_hash/service'

module External
Expand Down
2 changes: 0 additions & 2 deletions source/server/app.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'app_base'
require_relative 'differ'
require_relative 'prober'
Expand Down
2 changes: 0 additions & 2 deletions source/server/app_base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'silently'
silently { require 'sinatra/contrib' } # N x "warning: method redefined"
require_relative 'http_json_hash/service'
Expand Down
2 changes: 0 additions & 2 deletions source/server/config/config.ru
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

$stdout.sync = true
$stderr.sync = true

Expand Down
1 change: 0 additions & 1 deletion source/server/config/puma.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env puma
# frozen_string_literal: true

environment('production')
rackup("#{__dir__}/config.ru")
5 changes: 3 additions & 2 deletions source/server/config/up.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash -Eeu
#!/usr/bin/env bash
set -Eeu

readonly PORT="${CYBER_DOJO_DIFFER_PORT}"
readonly MY_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

export RUBYOPT='-W2'
export RUBYOPT='-W2 --enable-frozen-string-literal'

puma \
--port=${PORT} \
Expand Down
2 changes: 0 additions & 2 deletions source/server/differ.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'git_differ'
require_relative 'git_diff_parser'

Expand Down
2 changes: 0 additions & 2 deletions source/server/external/disk_writer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module External
class DiskWriter
def write(pathed_filename, content)
Expand Down
2 changes: 0 additions & 2 deletions source/server/external/gitter.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module External
class Gitter
def initialize(externals)
Expand Down
2 changes: 0 additions & 2 deletions source/server/external/http.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require 'net/http'

module External
Expand Down
2 changes: 0 additions & 2 deletions source/server/external/saver.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative '../http_json_hash/service'

module External
Expand Down
2 changes: 0 additions & 2 deletions source/server/external/sheller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative '../utf8_clean'
require 'open3'

Expand Down
2 changes: 0 additions & 2 deletions source/server/externals.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'external/disk_writer'
require_relative 'external/gitter'
require_relative 'external/http'
Expand Down
2 changes: 0 additions & 2 deletions source/server/git_diff_parse_filenames.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module GitDiffParseFilenames
def parse_old_new_filenames(header)
old_filename, new_filename = old_new_filenames(header[0])
Expand Down
2 changes: 0 additions & 2 deletions source/server/git_diff_parser.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'git_diff_parse_filenames'

class GitDiffParser
Expand Down
2 changes: 0 additions & 2 deletions source/server/git_differ.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class GitDiffer
def initialize(external)
@external = external
Expand Down
2 changes: 0 additions & 2 deletions source/server/http_json_hash/requester.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require 'json'
require 'uri'

Expand Down
2 changes: 0 additions & 2 deletions source/server/http_json_hash/service.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'requester'
require_relative 'unpacker'

Expand Down
2 changes: 0 additions & 2 deletions source/server/http_json_hash/service_error.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module HttpJsonHash
class ServiceError < RuntimeError
def initialize(name, path, args, body, message)
Expand Down
2 changes: 0 additions & 2 deletions source/server/http_json_hash/unpacker.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'service_error'
require 'json'

Expand Down
2 changes: 0 additions & 2 deletions source/server/prober.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class Prober
def initialize(externals)
@externals = externals
Expand Down
2 changes: 0 additions & 2 deletions source/server/silently.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

def silently
old_stderr = $stderr
$stderr = StringIO.new
Expand Down
2 changes: 0 additions & 2 deletions source/server/utf8_clean.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Utf8
def self.clean(str)
# force an encoding change - if encoding is already utf-8
Expand Down
2 changes: 0 additions & 2 deletions test/client/client_test_base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'lib/id58_test_base'
require_app 'differ'
require_app 'saver'
Expand Down
2 changes: 0 additions & 2 deletions test/client/differ_client_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'client_test_base'
require 'cgi'

Expand Down
2 changes: 0 additions & 2 deletions test/client/http_response_unpacker_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'client_test_base'
require_app 'http_json_hash/unpacker'
require 'ostruct'
Expand Down
2 changes: 0 additions & 2 deletions test/client/lib/check_metrics.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require 'json'

def coloured(arg)
Expand Down
2 changes: 0 additions & 2 deletions test/client/lib/coverage.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require 'simplecov'
require_relative 'simplecov_formatter_json'

Expand Down
2 changes: 0 additions & 2 deletions test/client/lib/coverage_metrics_limits.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

def metrics
[
[ nil ],
Expand Down
2 changes: 0 additions & 2 deletions test/client/lib/id58_test_base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require 'English'
require 'minitest/autorun'
require 'minitest/reporters'
Expand Down
2 changes: 1 addition & 1 deletion test/client/lib/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ require '${MY_DIR}/coverage.rb'
require file
}"

export RUBYOPT='-W2'
mkdir -p "${COVERAGE_ROOT}"

set +e
export RUBYOPT='-W2 --enable-frozen-string-literal'
ruby -e "${SCRIPT}" -- ${TEST_ARGS[@]} 2>&1 | tee "${COVERAGE_ROOT}/${TEST_LOG}"
STATUS=${PIPESTATUS[0]}
set -e
Expand Down
2 changes: 0 additions & 2 deletions test/client/lib/simplecov_formatter_json.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require 'simplecov'
require 'json'

Expand Down
2 changes: 0 additions & 2 deletions test/client/lib/slim_json_reporter.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require 'json'
require 'minitest/reporters'

Expand Down
2 changes: 0 additions & 2 deletions test/client/lib/test_metrics_limits.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

def metrics
[
[ nil ],
Expand Down
2 changes: 0 additions & 2 deletions test/server/diff_summary_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require_relative 'differ_test_base'

class DiffSummaryTest < DifferTestBase
Expand Down
Loading