Skip to content

Commit

Permalink
Merge pull request #14 from tonybaloney/fix_unsafe_cast
Browse files Browse the repository at this point in the history
Fix unsafe cast
  • Loading branch information
tonybaloney authored Jan 20, 2020
2 parents a7a5b71 + c98f97f commit 4a09c15
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release History

## 1.0.13

* Added [Django CSRF Middleware Validator](doc/checks/DJG200.md)
* Added [Django Clickjack Middleware Validator](doc/checks/DJG201.md)
* Added Django Middleware Fixer
* Fixed bug where function references would be unsafely cast to a PyReferenceExpression and cause a fault

## 1.0.12

* Added [Shell Escape Fixer](doc/fixes/shellescapefixer.md), recommended by [PR100](doc/checks/PR100.md)
Expand Down
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group 'org.tonybaloney.security'
version '1.0.12'
version '1.0.13'

repositories {
mavenCentral()
Expand All @@ -33,10 +33,12 @@ intellij {

patchPluginXml {
changeNotes """
<h2>1.0.12</h2>
<h2>1.0.13</h2>
<ul>
<li>Added a quick-fix for escaping shell input</li>
<li>More scenarios for shell injection detection</li>
<li>Added Django CSRF Middleware Validator </li>
<li>Added Django Clickjack Middleware Validator </li>
<li>Added Django Middleware Fixer </li>
<li>Fixed bug where function references would be unsafely cast to a PyReferenceExpression and cause a fault </li>
</ul>"""
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/security/helpers/QualifiedNames.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ object QualifiedNames {
val markedCallees = callExpression.multiResolveCallee(resolveContext)
if (markedCallees.isEmpty()) {
val firstChild = callExpression.firstChild ?: return null
val qualifiedName = (firstChild as PyReferenceExpression).asQualifiedName() ?: return null;
if (firstChild !is PyReferenceExpression) return null
val qualifiedName = (firstChild).asQualifiedName() ?: return null;
return qualifiedName.toString()
}
else
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/security/helpers/QualifiedNamesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ class QualifiedNamesTest: SecurityTestTask() {
assertEquals(getQualifiedName(code), "math.floor")
}

@Test
fun `test double brackets reference no arguments`(){
var code = """
import math
math.floor()()
""".trimIndent()
assertEquals(getQualifiedName(code), "math.floor")
}

private fun getQualifiedName(code: String): String?{
var name: String? = null
ApplicationManager.getApplication().runReadAction {
Expand Down

0 comments on commit 4a09c15

Please sign in to comment.