From 49b49b20c8f6e142723dac243dc28aa32ce3a70b Mon Sep 17 00:00:00 2001 From: Jaroslav Novotny Date: Fri, 14 Oct 2022 23:35:27 +0200 Subject: [PATCH 1/9] chore: Added templates --- .github/ISSUE_TEMPLATE/bug_report.md | 29 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/chore.md | 14 +++++++++++ .github/ISSUE_TEMPLATE/config.yml | 1 + .github/ISSUE_TEMPLATE/documentation.md | 14 +++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 18 ++++++++++++++ .github/ISSUE_TEMPLATE/refactor.md | 14 +++++++++++ .github/ISSUE_TEMPLATE/revert.md | 16 +++++++++++++ .github/ISSUE_TEMPLATE/style.md | 14 +++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 27 +++++++++++++++++++++ 9 files changed, 147 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/chore.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/documentation.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/refactor.md create mode 100644 .github/ISSUE_TEMPLATE/revert.md create mode 100644 .github/ISSUE_TEMPLATE/style.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..50a4c7b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug Report +about: Create a report to help us improve +title: "fix: " +labels: bug +--- + +**Description** + +A clear and concise description of what the bug is. + +**Steps To Reproduce** + +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected Behavior** + +A clear and concise description of what you expected to happen. + +**Screenshots** + +If applicable, add screenshots to help explain your problem. + +**Additional Context** + +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/chore.md b/.github/ISSUE_TEMPLATE/chore.md new file mode 100644 index 0000000..498ebfd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/chore.md @@ -0,0 +1,14 @@ +--- +name: Chore +about: Other changes that don't modify src or test files +title: "chore: " +labels: chore +--- + +**Description** + +Clearly describe what change is needed and why. If this changes code then please use another issue type. + +**Requirements** + +- [ ] No functional changes to the code diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..ec4bb38 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/documentation.md b/.github/ISSUE_TEMPLATE/documentation.md new file mode 100644 index 0000000..f494a4d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.md @@ -0,0 +1,14 @@ +--- +name: Documentation +about: Improve the documentation so all collaborators have a common understanding +title: "docs: " +labels: documentation +--- + +**Description** + +Clearly describe what documentation you are looking to add or improve. + +**Requirements** + +- [ ] Requirements go here diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..ddd2fcc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,18 @@ +--- +name: Feature Request +about: A new feature to be added to the project +title: "feat: " +labels: feature +--- + +**Description** + +Clearly describe what you are looking to add. The more context the better. + +**Requirements** + +- [ ] Checklist of requirements to be fulfilled + +**Additional Context** + +Add any other context or screenshots about the feature request go here. diff --git a/.github/ISSUE_TEMPLATE/refactor.md b/.github/ISSUE_TEMPLATE/refactor.md new file mode 100644 index 0000000..1626c57 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/refactor.md @@ -0,0 +1,14 @@ +--- +name: Refactor +about: A code change that neither fixes a bug nor adds a feature +title: "refactor: " +labels: refactor +--- + +**Description** + +Clearly describe what needs to be refactored and why. Please provide links to related issues (bugs or upcoming features) in order to help prioritize. + +**Requirements** + +- [ ] There is no drop in test coverage. diff --git a/.github/ISSUE_TEMPLATE/revert.md b/.github/ISSUE_TEMPLATE/revert.md new file mode 100644 index 0000000..9d121dc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/revert.md @@ -0,0 +1,16 @@ +--- +name: Revert Commit +about: Reverts a previous commit +title: "revert: " +labels: revert +--- + +**Description** + +Provide a link to a PR/Commit that you are looking to revert and why. + +**Requirements** + +- [ ] Change has been reverted +- [ ] No change in test coverage has happened +- [ ] A new ticket is created for any follow on work that needs to happen diff --git a/.github/ISSUE_TEMPLATE/style.md b/.github/ISSUE_TEMPLATE/style.md new file mode 100644 index 0000000..73021a3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/style.md @@ -0,0 +1,14 @@ +--- +name: Style Changes +about: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) +title: "style: " +labels: style +--- + +**Description** + +Clearly describe what you are looking to change and why. + +**Requirements** + +- [ ] There is no drop in test coverage. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..1169936 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,27 @@ + + +## Status + +**READY/IN DEVELOPMENT/HOLD** + +## Description + + + +## Type of Change + + + +- [ ] โœจ New feature (non-breaking change which adds functionality) +- [ ] ๐Ÿ› ๏ธ Bug fix (non-breaking change which fixes an issue) +- [ ] โŒ Breaking change (fix or feature that would cause existing functionality to change) +- [ ] ๐Ÿงน Code refactor +- [ ] โœ… Build configuration change +- [ ] ๐Ÿ“ Documentation +- [ ] ๐Ÿ—‘๏ธ Chore From 751099a5070a5d4bc3228bcd66448cbe6f1bdeb8 Mon Sep 17 00:00:00 2001 From: Jaroslav Novotny Date: Fri, 14 Oct 2022 23:38:31 +0200 Subject: [PATCH 2/9] chore: Updated description and version. Removed pre-generated comments. --- brick.yaml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/brick.yaml b/brick.yaml index 351bc60..3c054e1 100644 --- a/brick.yaml +++ b/brick.yaml @@ -1,25 +1,11 @@ name: freerasp_brick -description: A new brick created with the Mason CLI. +description: A brick for configuration generation and automatic setup for freeRASP. -# The following defines the version and build number for your brick. -# A version number is three numbers separated by dots, like 1.2.34 -# followed by an optional build number (separated by a +). -version: 0.1.0+1 +version: 0.0.1-dev.1 -# The following defines the environment for the current brick. -# It includes the version of mason that the brick requires. environment: mason: ">=0.1.0-dev.26 <0.1.0" -# Variables specify dynamic values that your brick depends on. -# Zero or more variables can be specified for a given brick. -# Each variable has: -# * a type (string, number, boolean, enum, or array) -# * an optional short description -# * an optional default value -# * an optional list of default values (array only) -# * an optional prompt phrase used when asking for the variable -# * a list of values (enums only) vars: name: type: string From 4a94a3de8a7fc2a95dacab6778e33f0e9838f01d Mon Sep 17 00:00:00 2001 From: Jaroslav Novotny Date: Sat, 15 Oct 2022 19:33:32 +0200 Subject: [PATCH 3/9] docs: Updated docs --- README.md | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5e7dd69..b56a4e5 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,53 @@ # freerasp_brick -[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason) +

+Powered by Mason +Supported freeRASP +License: MIT +

-A new brick created with the Mason CLI. +

+A brick to automate configuration of freeRASP freeRASP. +

-_Generated by [mason][1] ๐Ÿงฑ_ +A brick to automate work with [freeRASP][8]. -## Getting Started ๐Ÿš€ +## How to use ๐Ÿš€ -This is a starting point for a new brick. -A few resources to get you started if this is your first brick template: +``` +mason make freerasp_brick +``` +## Variables ๐Ÿ“ฆ +| Variable | Description | Default | Type | Conditional | When | +|--------------|-------------------------------|-----------------|--------|-------------|-----------------| +| watcher_mail | An email for security reports | N/A | String | false | N/A | +| android | Add Android configuration | true | bool | false | N/A | +| package_name | Android app package name | com.example.app | String | true | android == true | +| signing_hash | Android app signing hash | N/A | String | true | android == true | +| ios | Add iOS configuration | true | bool | false | N/A | +| bundle_id | iOS app id | com.example.app | String | true | ios == true | +| team_id | iOS team id | N/A | String | true | ios == true | + +## Hooks ๐Ÿช +| Type | Enabled | Can be disabled | +|----------|---------|-----------------| +| pre-gen | โœ… | โŒ | +| post-gen | โœ… | โŒ | + +## Getting started with [mason][1] ๐Ÿงฑ + +If this is your first touch with mason, please refer to resources to get started: + +- [Mason on pub.dev][1] - [Official Mason Documentation][2] - [Code generation with Mason Blog][3] - [Very Good Livestream: Felix Angelov Demos Mason][4] [1]: https://github.com/felangel/mason + [2]: https://github.com/felangel/mason/tree/master/packages/mason_cli#readme + [3]: https://verygood.ventures/blog/code-generation-with-mason + [4]: https://youtu.be/G4PTjA6tpTU From a44aa15ac27a5af9005aaa7f7be6c374720e4f45 Mon Sep 17 00:00:00 2001 From: Jaroslav Novotny Date: Sat, 15 Oct 2022 19:54:41 +0200 Subject: [PATCH 4/9] docs: Updated README.md --- README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b56a4e5..9fba219 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,34 @@ A brick to automate configuration of freeRASP freeRASP.

-A brick to automate work with [freeRASP][8]. +> ๐Ÿšง This brick experimental and not stable! Changes to API reserved. ๐Ÿšง + +## Overview +Setting up freeRASP can be quite tedious and repetitive. freerasp_brick provides you error-prone +way to create configuration. + +## Features ๐Ÿงฐ +- ๐Ÿ›  Configuration generation +- ๐ŸŽฏ Dependency check using `pub get` +- ๐Ÿ”ง Fix apply using `dart fix` ## How to use ๐Ÿš€ +Generate configuration: ``` mason make freerasp_brick ``` +Import it and call `start()`: +```dart +import 'freerasp/freerasp.g.dart'; + +talsec.start(); +``` + +You can edit `freerasp_callback.g.dart` to provide own reactions or made your own `TalsecCallback` +and provide it in `freerasp.g.dart`; + ## Variables ๐Ÿ“ฆ | Variable | Description | Default | Type | Conditional | When | |--------------|-------------------------------|-----------------|--------|-------------|-----------------| @@ -29,7 +49,7 @@ mason make freerasp_brick | bundle_id | iOS app id | com.example.app | String | true | ios == true | | team_id | iOS team id | N/A | String | true | ios == true | -## Hooks ๐Ÿช +## Hooks ๐ŸŽฃ | Type | Enabled | Can be disabled | |----------|---------|-----------------| | pre-gen | โœ… | โŒ | From 4657a081f443b416f94b8b7a727887c8664bb732 Mon Sep 17 00:00:00 2001 From: Jaroslav Novotny Date: Sat, 15 Oct 2022 19:55:00 +0200 Subject: [PATCH 5/9] chore: Removed generated file --- __brick__/HELLO.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 __brick__/HELLO.md diff --git a/__brick__/HELLO.md b/__brick__/HELLO.md deleted file mode 100644 index 2f08230..0000000 --- a/__brick__/HELLO.md +++ /dev/null @@ -1 +0,0 @@ -Hello {{name}}! \ No newline at end of file From 5b57a1bc62a2f2a8b7233bb808d753e20f614070 Mon Sep 17 00:00:00 2001 From: Jaroslav Novotny Date: Sat, 15 Oct 2022 19:55:43 +0200 Subject: [PATCH 6/9] feat(config-generation): Added vars --- brick.yaml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/brick.yaml b/brick.yaml index 3c054e1..d718c2a 100644 --- a/brick.yaml +++ b/brick.yaml @@ -7,8 +7,17 @@ environment: mason: ">=0.1.0-dev.26 <0.1.0" vars: - name: + watcher_mail: type: string - description: Your name - default: Dash - prompt: What is your name? + description: Watcher mail + prompt: An email for security reports + android: + type: boolean + description: Add Android configuration + prompt: Add Android configuration? + default: true + ios: + type: boolean + description: Add iOS configuration + prompt: Add iOS configuration? + default: true From 1c89608fc2ebb45166c9de0f24033d5e7add7919 Mon Sep 17 00:00:00 2001 From: Jaroslav Novotny Date: Sat, 15 Oct 2022 19:56:00 +0200 Subject: [PATCH 7/9] feat(config-generation): Added generation templates --- __brick__/lib/freerasp/freerasp.g.dart | 19 +++++++++++++++ .../lib/freerasp/freerasp_callback.g.dart | 23 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 __brick__/lib/freerasp/freerasp.g.dart create mode 100644 __brick__/lib/freerasp/freerasp_callback.g.dart diff --git a/__brick__/lib/freerasp/freerasp.g.dart b/__brick__/lib/freerasp/freerasp.g.dart new file mode 100644 index 0000000..5e3bd33 --- /dev/null +++ b/__brick__/lib/freerasp/freerasp.g.dart @@ -0,0 +1,19 @@ +import 'package:freerasp/talsec_app.dart'; +part 'freerasp_callback.g.dart'; + +TalsecConfig _config = TalsecConfig( + watcherMail: '{{watcher_mail}}',{{#android}} + androidConfig: AndroidConfig( + expectedPackageName: '{{package_name}}', + expectedSigningCertificateHash: '{{signing_hash}}', + ),{{/android}}{{#ios}} + iosConfig: IOSconfig( + appBundleId: '{{bundle_id}}', + appTeamId: '{{team_id}}', + ),{{/ios}} +); + +TalsecApp talsec = TalsecApp( + config: _config, + callback: callback, +); diff --git a/__brick__/lib/freerasp/freerasp_callback.g.dart b/__brick__/lib/freerasp/freerasp_callback.g.dart new file mode 100644 index 0000000..c3582d9 --- /dev/null +++ b/__brick__/lib/freerasp/freerasp_callback.g.dart @@ -0,0 +1,23 @@ +part of 'freerasp.g.dart'; + +final callback = TalsecCallback({{#android}} + androidCallback: AndroidCallback( + onRootDetected: () => print('root'), + onEmulatorDetected: () => print('emulator'), + onHookDetected: () => print('hook'), + onTamperDetected: () => print('tamper'), + onDeviceBindingDetected: () => print('device binding'), + onUntrustedInstallationDetected: () => print('untrusted install'), + ), {{/android}} {{#ios}} + iosCallback: IOSCallback( + onSignatureDetected: () => print('signature'), + onRuntimeManipulationDetected: () => print('runtime manipulation'), + onJailbreakDetected: () => print('jailbreak'), + onPasscodeDetected: () => print('passcode'), + onSimulatorDetected: () => print('simulator'), + onMissingSecureEnclaveDetected: () => print('secure enclave'), + onDeviceChangeDetected: () => print('device change'), + onDeviceIdDetected: () => print('device ID'), + onUnofficialStoreDetected: () => print('unofficial store')), {{/ios}} + onDebuggerDetected: () => print('debugger'), +); From a26c9af2a2dc34c9d9e53f13b1fad7bc0589880a Mon Sep 17 00:00:00 2001 From: Jaroslav Novotny Date: Sat, 15 Oct 2022 19:56:10 +0200 Subject: [PATCH 8/9] feat(config-generation): Added hooks --- hooks/post_gen.dart | 29 +++++++++++++++++++++++++++++ hooks/pre_gen.dart | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/hooks/post_gen.dart b/hooks/post_gen.dart index e69de29..cbd0494 100644 --- a/hooks/post_gen.dart +++ b/hooks/post_gen.dart @@ -0,0 +1,29 @@ +import 'dart:io'; + +import 'package:mason/mason.dart'; + +const String androidBuild = 'build.gradle'; +const String flutterBuild = 'lib'; + +void run(HookContext context) async { + final logger = context.logger; + + await _runPub(logger); + await _runDartFix(logger); +} + +Future _runPub(Logger logger) async { + final progress = logger.progress('Running dart pub get'); + final result = await Process.run('dart', ['pub', 'get']); + return result.exitCode == 0 + ? progress.complete('Pub get run successfully') + : progress.fail('Pub get failed. Please handle dependency manually.'); +} + +Future _runDartFix(Logger logger) async { + final progress = logger.progress('Running dart fix --apply'); + final result = await Process.run('dart', ['fix', '--apply']); + return result.exitCode == 0 + ? progress.complete('Fix applied.') + : progress.fail('Fix couldn\'t be applied'); +} diff --git a/hooks/pre_gen.dart b/hooks/pre_gen.dart index e69de29..c5ceaf4 100644 --- a/hooks/pre_gen.dart +++ b/hooks/pre_gen.dart @@ -0,0 +1,39 @@ +import 'package:mason/mason.dart'; + +const defaultAppPackage = 'com.example.app'; + +void run(HookContext context) { + final isAndroid = context.vars['android']; + final isIOS = context.vars['ios']; + + if (isAndroid) parseAndroidData(context); + + if (isIOS) parseCupertinoData(context); +} + +void parseCupertinoData(HookContext context) { + final logger = context.logger; + + final bundleId = + logger.prompt("What's app bundle ID?", defaultValue: defaultAppPackage); + final teamId = + logger.prompt("What's app team ID?", defaultValue: defaultAppPackage); + + context.vars.addAll({ + 'bundle_id': bundleId, + 'team_id': teamId, + }); +} + +void parseAndroidData(HookContext context) { + final logger = context.logger; + + final packageName = logger.prompt("What's app package name?", + defaultValue: defaultAppPackage); + final signingHash = logger.prompt("What's app singing hash?"); + + context.vars.addAll({ + 'package_name': packageName, + 'signing_hash': signingHash, + }); +} From 8fe22ccf55691f0a60764e8b335c652c63c7e7a7 Mon Sep 17 00:00:00 2001 From: Jaroslav Novotny Date: Sat, 15 Oct 2022 20:00:39 +0200 Subject: [PATCH 9/9] docs: Added LICENSE --- LICENSE | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index ba75c69..0f97715 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1,21 @@ -TODO: Add your license here. +MIT License + +Copyright (c) 2022 Jaroslav Novotny + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file