-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to write custom rules for only specific file? #1077
Comments
hello @ne0z this is really great idea tnks \o/ but currently this is not possible, because as you can see in this logic we have a restriction on which extensions we can analyze this rule, an implementation would be needed to analyze by file name, I will add this improvement in our backlog, but feel free to contribute too \o/ |
@wiliansilvazup Thanks ! But, I don't know from where to start the contribution. I mean about "analyze by file name". Is it mean to create another format rules? or just give an additional JSON field on the existing format rules? Example "files" as a new JSON field:
Also I am not sure scanning AndroidManifest.xml file with Leaks language. Because based on the name, Leaks is more relevant if the rules related with "information leaks". I have look another language options but other language seems more irrelevant. Any ideas about this? |
I understand, to make the change you will need: 2nd Soon after, it will be necessary to add validation in the method runRule so that it can find vulnerability only if the directory is found. You can use the same library double-star that we used in horusec to perform validation of which file we should ignore in the specific rule. |
Hi @wiliansilvazup, I have added some changes but I am not sure if that PR is correct, the validation implemented in the Run method https://github.com/ZupIT/horusec-engine/blob/421af642c0468e1f641cd714e795a3ec6c27dc20/text/rule.go#L71 because I can access the metadata information inside or am I misunderstanding this somehow? |
@ne0z for check if this changes are be ok you can create unit tests for validate. By exemple "Temporarily create files in json, yaml, go, javascript, etc.", but looking your updates i think this can works fine :) |
Hi @wiliansilvazup, I have added the unit test and fixed the linter on the ZupIT/horusec-engine#120. Any other suggestions? :) |
What happened:
Currently, I use Horusec to scan android application. In my use case, I want to implement OWASP Mobile Security Testing Checklist. One of my use cases the specific file AndroidManifest.xml should have attribute
android:allowBackup="false"
. for an example:So, how to write custom rules to specific files that they should contains what we want?
I have tried read docs there have RegExps type
NotMatch
but when I tried this Regexps all files will be detected as findings.Reference: https://mobile-security.gitbook.io/mobile-security-testing-guide/android-testing-guide/0x05d-testing-data-storage#testing-backups-for-sensitive-data-mstg-storage-8
How to reproduce it (as minimally and precisely as possible):
cd Android-InsecureBankv2 horusec generate
horusec start -p . -c ./custom-rules.json
Anything else we need to know?:
All files detected by custom rules, not only AndroidManifest.xml
Environment: Ubuntu 20.04
horusec version
): v2.6.4The text was updated successfully, but these errors were encountered: