Skip to content

Instantly share code, notes, and snippets.

val isSafe = safeToRun(
{ banAvdEmulatorCheck() },
{ banGenymotionEmulatorCheck() },
{ banBluestacksEmulatorCheck() },
{ isDebuggableCheck() },
{ rootDetectionCheck() }
)
if (!isSafe) {
throw RuntimeException("Device is not safe to run")
fun saveFile(fileName: String, content: String) {
val file = File("/data/is/safe/to/go/here", fileName)
val isSafe = file
.verifyFile(this) {
File("/data/is/safe/to/go/here").allowDirectory()
}
if (isSafe) { // Without this check - what would happen? Bad things..
file.writeText(content)
}
inline fun Context.verifyDevice(): Boolean {
val checks = safeToRun(
{ banDebugCheck() },
{ blacklistedAppCheck("com.abc") },
{ safeToRunCombinedCheck(
listOf { minOsVersionCheck(31) },
listOf { minOsVersionCheck(30) }
)
},
{ verifySignatureCheck("ABASDASD", "BBBBBBB") },
@dllewellyn
dllewellyn / url_verification.kt
Last active November 19, 2022 19:24
Example of url verification code
fun mySecureFunction(websiteUrl : String) {
val isSafe = websiteUrl.urlVerification {
"safetorun.com".allowHost()
}
if (isSafe) {
loadUrl(websiteUrl)
}
}
if (TuroblinksUrlHandler.contains(url, "/verify?", true)) {
C3982h.nullCheck(url, "$this$proceedToParam");
C3982h.nullCheck(url, "$this$extractQueryParam");
C3982h.nullCheck("proceed_to", "queryKey");
String queryParameter = url.toUri().getQueryParameter("proceed_to");
url = queryParameter != null ? UrlKt.parseUrl(queryParameter) : null;
C3982h.nullCheck(url);
}
Intent intent10 = new Intent(context, WebViewActivity.class);
SafeToRun.init(
configure {
// Root beer (detect root)
rootDetection {
tolerateRoot = false
tolerateBusyBox = true
}.error()
// Black list certain apps
import SwiftUI
import shared
class ContentViewProxy : ObservableObject {
@Published
var listItems : [ListEntry] = []
let repository = DefaultListItemRepository()
// Set of Material typography styles to start with
val typography = Typography(
body1 = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
)
/* Other default text styles to override
button = TextStyle(
fontFamily = FontFamily.Default,
val shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp)
)
import androidx.compose.ui.graphics.Color
val purple200 = Color(0xFFBB86FC)
val purple500 = Color(0xFF6200EE)
val purple700 = Color(0xFF3700B3)
val teal200 = Color(0xFF03DAC5)