This repository was archived by the owner on Dec 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Changed naming of checks from SecurityCheck to DeviceCheck #85
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
90e2767
Changed naming of checks from SecurityCheck to DeviceCheck
ziccardi f27f028
Removed double negatives from Android checks
ziccardi d69f5c3
Removed double negatives for ios checks
ziccardi 1ea68f7
Fixed some naming
ziccardi 7ab593e
Undo nuget.packages update
ziccardi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule Example
updated
11 files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,26 +7,26 @@ namespace AeroGear.Mobile.Security.Checks | |
| /// <summary> | ||
| /// A check for whether the device the application is running on an emulator. | ||
| /// </summary> | ||
| public class NotInEmulatorCheck : AbstractSecurityCheck | ||
| public class EmulatorCheck : AbstractDeviceCheck | ||
|
||
| { | ||
| protected override string Name => "Emulator Check"; | ||
|
|
||
| private readonly Context context; | ||
|
|
||
| public NotInEmulatorCheck(Context ctx) | ||
| public EmulatorCheck(Context ctx) | ||
| { | ||
| this.context = ctx; | ||
| } | ||
|
|
||
| public override SecurityCheckResult Check() | ||
| public override DeviceCheckResult Check() | ||
| { | ||
| if (Build.Fingerprint != null) | ||
| { | ||
| if (Build.Fingerprint.Contains("vbox") || | ||
| Build.Fingerprint.Contains("generic")) | ||
| return new SecurityCheckResult(this, false); | ||
| return new DeviceCheckResult(this, true); | ||
| } | ||
| return new SecurityCheckResult(this, true); | ||
| return new DeviceCheckResult(this, false); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using AeroGear.Mobile.Core.Utils; | ||
| using AeroGear.Mobile.Security.Checks; | ||
|
|
||
| namespace AeroGear.Mobile.Security | ||
| { | ||
| /// <summary> | ||
| /// This class enums all the provided security checks. | ||
| /// | ||
| /// To get an instance of the check, use the following code: | ||
| /// <code> | ||
| /// <![CDATA[ | ||
| /// var deviceChek = ServiceFinder.Resolve<IDeviceCheckFactory>().create(DeviceChecks.NOT_ROOTED); | ||
| /// ]]> | ||
| /// </code> | ||
| /// </summary> | ||
| public class DeviceChecks : IDeviceCheckType | ||
| { | ||
| private static Dictionary<string, DeviceChecks> typesByName = new Dictionary<string, DeviceChecks>(); | ||
|
|
||
| public static readonly DeviceChecks ROOT_ENABLED = new DeviceChecks(typeof(RootEnabledCheck)); | ||
| public static readonly DeviceChecks DEVELOPER_MODE_ENABLED = new DeviceChecks(typeof(DeveloperModeEnabledCheck)); | ||
| public static readonly DeviceChecks IS_EMULATOR = new DeviceChecks(typeof(EmulatorCheck)); | ||
| public static readonly DeviceChecks SCREEN_LOCK_ENABLED = new DeviceChecks(typeof(ScreenLockEnabledCheck)); | ||
| public static readonly DeviceChecks BACKUP_ALLOWED = new DeviceChecks(typeof(BackupAllowedCheck)); | ||
| public static readonly DeviceChecks ENCRYPTION_ENABLED = new DeviceChecks(typeof(EncryptionEnabledCheck)); | ||
| public static readonly DeviceChecks DEBUGGER_ENABLED = new DeviceChecks(typeof(DebuggerEnabledCheck)); | ||
|
|
||
| // add others checks here | ||
| // i.e. | ||
| // public static readonly DeviceChecks NO_DEBUGGER = new DeviceChecks(typeof(NoDebuggerCheck)); | ||
| // this way the user will be able to do an enum like selection: | ||
| // DeviceChecks.NOT_JAILBROKEN | ||
|
|
||
| internal readonly Type CheckType; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="T:AeroGear.Mobile.Security.DeviceChecks"/> class. | ||
| /// Private so that it can't be instantiated externally: useful to emulate an enum. | ||
| /// </summary> | ||
| /// <param name="checkType">The class type of the check represented by this instance.</param> | ||
| private DeviceChecks(Type checkType, string friendlyName = null) | ||
| { | ||
| if (!ServiceFinder.IsRegistered<IDeviceCheckFactory>()) | ||
| { | ||
| ServiceFinder.RegisterInstance<IDeviceCheckFactory>(AndroidDeviceCheckFactory.INSTANCE); | ||
| } | ||
|
|
||
| this.CheckType = checkType; | ||
| typesByName[friendlyName ?? checkType.Name] = this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns an the DeviceChecks instance identified by the passed in name. | ||
| /// </summary> | ||
| /// <returns>The DeviceChecks instance identified by the passed in name or <code>null</code> if not found.</returns> | ||
| /// <param name="name">Name.</param> | ||
| public static DeviceChecks GetDeviceCheck(string name) | ||
| { | ||
| if (typesByName.ContainsKey(name)) | ||
| { | ||
| return typesByName[name]; | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns all the checks. | ||
| /// </summary> | ||
| /// <returns>All the checks.</returns> | ||
| public static ICollection<DeviceChecks> GetAllChecks() | ||
| { | ||
| return typesByName.Values; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be renamed to
BackupEnabledCheck?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍