Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:doyensec/inql into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
execveat committed Oct 23, 2023
2 parents 1878a26 + 66e8a06 commit 611d61e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/main/kotlin/burp/BurpExtender.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import java.util.*
@Suppress("unused")
class BurpExtender : IBurpExtender, ExtensionUnloadingHandler, BurpExtension {

val version =
Properties().also { it.load(this.javaClass.getResourceAsStream("/version.properties")) }.getProperty("version")
?: ""
companion object {
val version =
Properties().also { it.load(this::class.java.getResourceAsStream("/version.properties")) }.getProperty("version") ?: ""
}
private lateinit var callbacks: IBurpExtenderCallbacks
private lateinit var inql: InQL

Expand Down Expand Up @@ -64,7 +65,7 @@ class BurpExtender : IBurpExtender, ExtensionUnloadingHandler, BurpExtension {
Burp.initialize(montoyaApi)

// Set the name of the extension
montoyaApi.extension().setName(if (version.isNotEmpty()) "InQL $version" else "InQL")
montoyaApi.extension().setName("InQL")

inql = InQL()
montoyaApi.extension().registerUnloadingHandler(this)
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/inql/InQL.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package inql

import burp.Burp
import burp.BurpExtender
import burp.BurpIcons
import burp.api.montoya.persistence.PersistedObject
import inql.attacker.Attacker
Expand Down Expand Up @@ -30,7 +31,7 @@ class InQL : TabbedPane(), SavesAndLoadData {
val attacker = Attacker(this)

init {
Burp.Montoya.logging().raiseInfoEvent("InQL Started")
Burp.Montoya.logging().raiseInfoEvent("InQL ${BurpExtender.version} Started")

// Cleanup from previous versions
// FIXME: Remove this once this is exposed through Settings UI
Expand Down
14 changes: 8 additions & 6 deletions src/main/kotlin/inql/graphql/formatting/SyntaxParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ import java.util.*
FloatValue
StringValue but """ starts a block string
*/
class SyntaxParser private constructor(val tokens: LinkedList<Token>, val fixIntrospection: Boolean = false) {
class SyntaxParser private constructor(val originalTokens: LinkedList<Token>, val fixIntrospection: Boolean = false) {
companion object {
fun parse(tokens: List<Token>, fixIntrospection: Boolean = false): List<Token> {
return SyntaxParser(LinkedList(tokens), fixIntrospection).parse()
}
}

/* Get only tokens with syntactic relevance */
val tokens = originalTokens.filter { t -> t.type != Token.Type.COMMENT && t.text != "," }

private var idx = 0

private val current: Token
Expand All @@ -34,13 +37,11 @@ class SyntaxParser private constructor(val tokens: LinkedList<Token>, val fixInt
Logger.error("Error while parsing GraphQL")
Logger.error((e.stackTraceToString()))
}
return this.tokens.filter { it.type != Token.Type.EMPTY }
return this.originalTokens.filter { it.type != Token.Type.EMPTY }
}

private fun consume() {
do {
idx++
} while (idx < this.tokens.size && (this.current.type == Token.Type.COMMENT || this.current.text == ","))
idx++
}

private fun consumeText(text: String) {
Expand All @@ -53,7 +54,8 @@ class SyntaxParser private constructor(val tokens: LinkedList<Token>, val fixInt
}

private fun delete() {
this.tokens[this.idx] = Token(Token.Type.EMPTY, "")
this.tokens[this.idx].type = Token.Type.EMPTY
this.tokens[this.idx].text = ""
}

private fun document() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/inql/graphql/formatting/Token.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package inql.graphql.formatting

import org.apache.commons.text.StringEscapeUtils

class Token(val type: Type, var text: String) {
class Token(var type: Type, var text: String) {

var subtype: Subtype = Subtype.NONE

Expand Down

0 comments on commit 611d61e

Please sign in to comment.