Skip to content

Provides custom lint rules developed by Bottle Rocket Studios to help keep our code cleaner, detect and mitigate possible security issues, and allow us to write rules around best practices and usage as necessary in the future

License

BottleRocketStudios/Android-CustomLintRules

Repository files navigation

Release

CustomLintRules

What this library does?

This library currently provides the following lint rules that detect unsupported characters in source and xml files:

  • TrojanSourceDetector - covers Java and Kotlin files
  • TrojanXmlDetector - covers XML resource and Android manifest files

A fatal lint error will be reported if any unicode (or unsupported ascii) characters are detected. Only printable(32..126) + horizontal tab/line feed/carriage return(9, 10, 13) ascii characters are allowed.

Usage

  1. Add jitpack in your root build gradle at the end of allprojects.repositories. Jitpack recommends adding to the end as Gradle will go through all repositories in order until it finds a dependency and jitpack likely accounts for a small portion of dependencies in your project:
allprojects {
    repositories {
        // ...
        maven(url = "https://jitpack.io")
    }
}
  1. Add the following to all your module build gradle files where you want to use the lint rules:
dependencies {
    // ...
    implementation("com.github.BottleRocketStudios:Android-CustomLintRules:1.0.0")
    // ...
}
  1. Perform a gradle sync and run the lint gradle task (gradlew lint). Any problems detected by the custom lint rules will be shown in the generated lint report.

Sample characters that will cause a lint error

Sample Lint Reports

View of the html lint report (generated via gradlew lint on your project)

a

Sample TrojanSource Lint Failure

a

Sample TrojanXml Lint Failure

a

Links

Details of the Trojan Source attack

Ascii reference

Build

Project structure

  • sample - Sample project containing source code and xml that will trigger the custom lint rules.
  • library - Android library project that packages up the lintRules into the library aar.
  • lintRules - actual source of the lint rules (with tests).

General

jitpack development/SNAPSHOT builds

  • Access development/SNAPSHOT builds by replacing the version with an arbitrary release tag, commit hash, or branch~name-SNAPSHOT (ex: develop-SNAPSHOT, feature~abc-SNAPSHOT). You can also browse https://jitpack.io/#BottleRocketStudios/Android-CustomLintRules to generate a dependency value from a list of all jitpack builds.
  • When debugging, you can view artifacts that gradle downloads to your local machine (from a consumer app POV) by navigating to the following folder and viewing its contents to inspect aars, module files, and pom files:
    • ~/.gradle/caches/modules-2/files-2.1/com.github.BottleRocketStudios/Android-CustomLintRules/

Local aar generation

  • You can generate a locally built aar for testing by executing the publishReleasePublicationToMavenLocal Run Configuration.
  • Quickly navigate to the output by executing the Open Local Maven Publication Folder Run Configuration.

Building custom lint rules links

About

Provides custom lint rules developed by Bottle Rocket Studios to help keep our code cleaner, detect and mitigate possible security issues, and allow us to write rules around best practices and usage as necessary in the future

Resources

License

Stars

Watchers

Forks