Skip to content

Commit 2957e0e

Browse files
authored
Merge branch 'main' into dependabot/bundler/rexml-3.2.8
2 parents bde602b + 87b5841 commit 2957e0e

18 files changed

+95
-96
lines changed

.github/workflows/kotlin-tests.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Kotlin Tests
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
test:
59
runs-on: ubuntu-latest # Assuming Kotlin projects can be built on Linux
@@ -21,7 +25,6 @@ jobs:
2125
${{ runner.os }}-gradle-
2226
- uses: ruby/setup-ruby@v1
2327
with:
24-
ruby-version: '3.2'
2528
bundler-cache: true # Runs 'bundle install' and caches installed gems automatically
2629
- name: Generate Kotlin Code & Run Tests
2730
run: bundle exec rake test_kotlin

.github/workflows/pull-request.yml

-18
This file was deleted.

.github/workflows/push.yml .github/workflows/run-tests.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ on:
33
push:
44
branches:
55
- main
6+
pull_request:
67
jobs:
78
test:
8-
env:
9-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
109
strategy:
1110
fail-fast: false
1211
matrix:
@@ -20,5 +19,5 @@ jobs:
2019
with:
2120
ruby-version: ${{ matrix.ruby }}
2221
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
23-
- name: Run tests
22+
- name: Run tests and linter
2423
run: bundle exec rake

.github/workflows/swift-tests.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Swift Tests
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
test:
59
runs-on: macos-latest
@@ -8,7 +12,6 @@ jobs:
812
- uses: actions/checkout@v2
913
- uses: ruby/setup-ruby@v1
1014
with:
11-
ruby-version: '3.1'
1215
bundler-cache: true # Runs 'bundle install' and caches installed gems automatically
1316
- name: Generate Swift Code & Run Tests
1417
run: bundle exec rake test_swift

.ruby-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.2
1+
3.3.3

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source "https://rubygems.org"
55
# Specify your gem's dependencies in arkana.gemspec
66
gemspec
77

8+
gem "bundler", "< 2.5" # 2.4.x is the latest that supports Ruby 2.7, which is the minimum required by Arkana
89
gem "rake"
910
gem "rspec"
1011
gem "rubocop"

Gemfile.lock

+32-39
Original file line numberDiff line numberDiff line change
@@ -10,61 +10,53 @@ GEM
1010
remote: https://rubygems.org/
1111
specs:
1212
ast (2.4.2)
13-
base64 (0.1.1)
14-
diff-lcs (1.5.0)
13+
diff-lcs (1.5.1)
1514
docile (1.4.0)
1615
dotenv (2.8.1)
17-
json (2.6.3)
16+
json (2.7.2)
1817
language_server-protocol (3.17.0.3)
19-
parallel (1.23.0)
20-
parser (3.2.2.3)
18+
parallel (1.25.1)
19+
parser (3.3.3.0)
2120
ast (~> 2.4.1)
2221
racc
2322
pastel (0.8.0)
2423
tty-color (~> 0.5)
25-
racc (1.7.1)
24+
racc (1.8.0)
2625
rainbow (3.1.1)
27-
rake (13.0.6)
28-
regexp_parser (2.8.1)
29-
rexml (3.2.8)
30-
strscan (>= 3.0.9)
31-
rspec (3.12.0)
32-
rspec-core (~> 3.12.0)
33-
rspec-expectations (~> 3.12.0)
34-
rspec-mocks (~> 3.12.0)
35-
rspec-core (3.12.2)
36-
rspec-support (~> 3.12.0)
37-
rspec-expectations (3.12.3)
26+
rake (13.2.1)
27+
regexp_parser (2.9.2)
28+
rexml (3.3.0)
29+
strscan
30+
rspec (3.13.0)
31+
rspec-core (~> 3.13.0)
32+
rspec-expectations (~> 3.13.0)
33+
rspec-mocks (~> 3.13.0)
34+
rspec-core (3.13.0)
35+
rspec-support (~> 3.13.0)
36+
rspec-expectations (3.13.0)
3837
diff-lcs (>= 1.2.0, < 2.0)
39-
rspec-support (~> 3.12.0)
40-
rspec-mocks (3.12.6)
38+
rspec-support (~> 3.13.0)
39+
rspec-mocks (3.13.1)
4140
diff-lcs (>= 1.2.0, < 2.0)
42-
rspec-support (~> 3.12.0)
43-
rspec-support (3.12.1)
44-
rubocop (1.56.3)
45-
base64 (~> 0.1.1)
41+
rspec-support (~> 3.13.0)
42+
rspec-support (3.13.1)
43+
rubocop (1.64.1)
4644
json (~> 2.3)
4745
language_server-protocol (>= 3.17.0)
4846
parallel (~> 1.10)
49-
parser (>= 3.2.2.3)
47+
parser (>= 3.3.0.2)
5048
rainbow (>= 2.2.2, < 4.0)
5149
regexp_parser (>= 1.8, < 3.0)
5250
rexml (>= 3.2.5, < 4.0)
53-
rubocop-ast (>= 1.28.1, < 2.0)
51+
rubocop-ast (>= 1.31.1, < 2.0)
5452
ruby-progressbar (~> 1.7)
5553
unicode-display_width (>= 2.4.0, < 3.0)
56-
rubocop-ast (1.29.0)
57-
parser (>= 3.2.1.0)
58-
rubocop-capybara (2.18.0)
59-
rubocop (~> 1.41)
60-
rubocop-factory_bot (2.23.1)
61-
rubocop (~> 1.33)
54+
rubocop-ast (1.31.3)
55+
parser (>= 3.3.1.0)
6256
rubocop-rake (0.6.0)
6357
rubocop (~> 1.0)
64-
rubocop-rspec (2.24.0)
65-
rubocop (~> 1.33)
66-
rubocop-capybara (~> 2.17)
67-
rubocop-factory_bot (~> 2.22)
58+
rubocop-rspec (3.0.1)
59+
rubocop (~> 1.61)
6860
ruby-progressbar (1.13.0)
6961
simplecov (0.22.0)
7062
docile (~> 1.1)
@@ -82,19 +74,20 @@ GEM
8274
tty-cursor (~> 0.7)
8375
tty-screen (~> 0.8)
8476
wisper (~> 2.0)
85-
tty-screen (0.8.1)
86-
unicode-display_width (2.4.2)
77+
tty-screen (0.8.2)
78+
unicode-display_width (2.5.0)
8779
wisper (2.0.1)
8880
yaml (0.3.0)
8981

9082
PLATFORMS
91-
arm64-darwin-21
83+
arm64-darwin-23
9284
ruby
9385
x86_64-darwin-19
9486
x86_64-linux
9587

9688
DEPENDENCIES
9789
arkana!
90+
bundler (< 2.5)
9891
rake
9992
rspec
10093
rubocop
@@ -104,4 +97,4 @@ DEPENDENCIES
10497
tty-prompt
10598

10699
BUNDLED WITH
107-
2.2.32
100+
2.3.27

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,21 @@ Usage: arkana [options]
139139
> [!NOTE]
140140
> For the complete set of args, look at the [options](#options) section.
141141
142-
### Config File
142+
## Config File
143143
144144
The `arkana.yml` would typically contain 3 important sections:
145145
146146
- **Environments**: This is typically where you specify `debug`, `release` or other environments which you wish to create.
147147
- **Environment Secrets**: This is where you declare the keys which will be ultimately exposed to your app, like `apiKey`.
148148
- **Global Secrets**: Here you'd declare keys which are the same across all environments.
149149
150-
### Environment File
150+
## Environment File
151151
152152
The environment (`.env`) file contains the actual secrets for each environment. While config file declares the keys, they are assigned encrypted values from this file.
153153
154154
This file is optional, but quite handy in local development. `.env` files shouldn't be committed as they contain your secrets. Instead, they should be stored in a secure location, like your CI/CD server as environment variables (all CI/CD servers have a way to store secrets securely). See [Continuous Integration](#continuous-integration) for more information.
155155
156-
#### Sample
156+
### Sample
157157
158158
A config file as shown below:
159159
@@ -420,9 +420,9 @@ This encoding mechanism makes it difficult for attackers to simply just read you
420420
Key security is difficult. Right now even the biggest apps get their keys [leaked](https://threatpost.com/twitter-oauth-api-keys-leaked-030713/77597). This is neatly summed up by John Adams of the Twitter Security Team on [Quora](http://www.quora.com/Twitter-1/How-were-the-Twitter-iPhone-and-Android-OAuth-keys-leaked).
421421
422422
> Putting this in the context of, "should you be storing keys in software", is more appropriate. Many companies do this. It's never a good idea.
423-
423+
>
424424
> When developers do that, other developers can use debuggers and string searching commands to extract those keys from the running application. There are numerous talks on how to do that, but leave that as an exercise to the reader to find those talks.
425-
425+
>
426426
> Many people believe that obfuscating these keys in code will help. It usually won't because you can just run a debugger and find the fully functional keys.
427427
428428
So in summary, the ideal way to store keys is to not store keys. In reality though most Apps embed keys, and this does that and adds some rudimentary obfuscation to the keys. A well motivated app cracker could probably extract this within a few minutes however.

Rakefile

+27-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require "bundler/gem_tasks"
44
require "rspec/core/rake_task"
55
require "tty-prompt"
6+
require "tmpdir"
67

78
RSpec::Core::RakeTask.new(:spec)
89

@@ -14,21 +15,28 @@ task default: %i[spec rubocop]
1415

1516
desc "Generates Swift source code and run its unit tests."
1617
task :test_swift do
17-
sh("ARKANA_RUNNING_CI_INTEGRATION_TESTS=true bin/arkana --config-filepath spec/fixtures/swift-tests.yml --dotenv-filepath spec/fixtures/.env.fruitloops --include-environments dev,staging")
18-
Dir.chdir("tests/MySecrets") do
18+
config_file = File.absolute_path("spec/fixtures/swift-tests.yml")
19+
dotenv_file = File.absolute_path("spec/fixtures/.env.fruitloops")
20+
with_temp_dir do |temp_dir|
21+
puts "Current working directory: #{temp_dir}"
22+
sh("ARKANA_RUNNING_CI_INTEGRATION_TESTS=true arkana --config-filepath #{config_file} --dotenv-filepath #{dotenv_file} --include-environments dev,staging")
23+
Dir.chdir("tests/MySecrets")
1924
sh("swift test")
2025
end
21-
FileUtils.rm_rf("tests")
2226
end
2327

2428
desc "Generates Kotlin source code and run its unit tests."
2529
task :test_kotlin do
26-
FileUtils.copy_entry("spec/fixtures/kotlin", "tests")
27-
sh("ARKANA_RUNNING_CI_INTEGRATION_TESTS=true bin/arkana --lang kotlin --config-filepath spec/fixtures/kotlin-tests.yml --dotenv-filepath spec/fixtures/.env.fruitloops --include-environments dev,staging")
28-
Dir.chdir("tests") do
30+
config_file = File.absolute_path("spec/fixtures/kotlin-tests.yml")
31+
dotenv_file = File.absolute_path("spec/fixtures/.env.fruitloops")
32+
directory_to_copy = File.absolute_path("spec/fixtures/kotlin")
33+
with_temp_dir do |temp_dir|
34+
puts "Current working directory: #{temp_dir}"
35+
FileUtils.copy_entry(directory_to_copy, "tests")
36+
sh("ARKANA_RUNNING_CI_INTEGRATION_TESTS=true arkana --lang kotlin --config-filepath #{config_file} --dotenv-filepath #{dotenv_file} --include-environments dev,staging")
37+
Dir.chdir("tests")
2938
sh("./gradlew test")
3039
end
31-
FileUtils.rm_rf("tests")
3240
end
3341

3442
desc "Sets lib version to the semantic version given, and push it to remote."
@@ -45,3 +53,15 @@ task :bump, [:v] do |_t, args|
4553
sh("git commit -m 'Bump app version to v#{version}.'")
4654
sh("git push origin")
4755
end
56+
57+
# Utilities
58+
59+
# Run tests in a different folder because when running in the same root folder as the gem,
60+
# there can be "relative_require" that happen to work in the test but wouldn't work when installing the gem in a different project.
61+
def with_temp_dir
62+
Dir.mktmpdir do |temp_dir|
63+
Dir.chdir(temp_dir) do
64+
yield temp_dir
65+
end
66+
end
67+
end

lib/arkana/encoder.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ def self.encode(string, cipher)
2626
result << (byte ^ cipher[index % cipher.length]) # XOR operation with a value of the cipher array.
2727
end
2828

29-
encoded_key = []
30-
result.each do |element|
29+
encoded_key = result.map do |element|
3130
# Warning: this might be specific to Swift implementation. When generating code for other languages, beware.
32-
encoded_key << format("%#x", element) # Format the binary number to "0xAB" format.
31+
format("%#x", element) # Format the binary number to "0xAB" format.
3332
end
3433

3534
encoded_key.join(", ")

lib/arkana/models/salt.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ class Salt
1010

1111
def initialize(raw:)
1212
@raw = raw
13-
formatted_salt = []
14-
raw.each do |element|
13+
formatted_salt = raw.map do |element|
1514
# Warning: this might be specific to Swift implementation. When generating code for other languages, beware.
16-
formatted_salt << format("%#x", element)
15+
format("%#x", element)
1716
end
1817
@formatted = formatted_salt.join(", ")
1918
end

lib/arkana/templates/kotlin/arkana.kt.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<% require_relative "lib/arkana/helpers/string" %>
2-
<% require_relative "lib/arkana/helpers/kotlin_template_helper" %>
1+
<% require "arkana/helpers/string" %>
2+
<% require "arkana/helpers/kotlin_template_helper" %>
33
<% # TODO: Sort these import statements alphabetically %>
44
// DO NOT MODIFY
55
// Automatically generated by Arkana (https://github.com/rogerluan/arkana)

lib/arkana/templates/kotlin/arkana_protocol.kt.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<% require_relative "lib/arkana/helpers/string" %>
2-
<% require_relative "lib/arkana/helpers/kotlin_template_helper" %>
1+
<% require "arkana/helpers/string" %>
2+
<% require "arkana/helpers/kotlin_template_helper" %>
33
// DO NOT MODIFY
44
// Automatically generated by Arkana (https://github.com/rogerluan/arkana)
55
package <%= @kotlin_package_name %>

lib/arkana/templates/kotlin/arkana_tests.kt.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<% require_relative "lib/arkana/helpers/string" %>
2-
<% require_relative "lib/arkana/helpers/kotlin_template_helper" %>
1+
<% require "arkana/helpers/string" %>
2+
<% require "arkana/helpers/kotlin_template_helper" %>
33
// DO NOT MODIFY
44
// Automatically generated by Arkana (https://github.com/rogerluan/arkana)
55
package <%= @kotlin_package_name %>

lib/arkana/templates/swift/arkana.swift.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<% require_relative "lib/arkana/helpers/string" %>
2-
<% require_relative "lib/arkana/helpers/swift_template_helper" %>
1+
<% require "arkana/helpers/string" %>
2+
<% require "arkana/helpers/swift_template_helper" %>
33
<% # TODO: Sort these import statements alphabetically %>
44
// DO NOT MODIFY
55
// Automatically generated by Arkana (https://github.com/rogerluan/arkana)

lib/arkana/templates/swift/arkana_protocol.swift.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<% require_relative "lib/arkana/helpers/string" %>
2-
<% require_relative "lib/arkana/helpers/swift_template_helper" %>
1+
<% require "arkana/helpers/string" %>
2+
<% require "arkana/helpers/swift_template_helper" %>
33
// DO NOT MODIFY
44
// Automatically generated by Arkana (https://github.com/rogerluan/arkana)
55

spec/models/config_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
end
5656
end
5757

58-
describe `#environment_keys` do
58+
describe "#environment_keys" do
5959
context "when there are no environments" do
6060
subject { super().environment_keys }
6161

@@ -130,7 +130,7 @@
130130
end
131131
end
132132

133-
describe `#all_keys` do
133+
describe "#all_keys" do
134134
it "is not empty" do
135135
expect(subject.all_keys).not_to be_empty
136136
end

spec/models/secret_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
end
1919
end
2020

21-
describe `#environment` do
21+
describe "#environment" do
2222
subject { super().environment }
2323

2424
context "when key is equal to protocol_key" do

0 commit comments

Comments
 (0)