Skip to content

Commit

Permalink
Remove analysis test code
Browse files Browse the repository at this point in the history
  • Loading branch information
bunseokbot committed Feb 17, 2021
1 parent 0d421a9 commit bc1dd45
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package project.namjun.kim.robster.analysis
import io.grpc.ManagedChannel
import io.grpc.ManagedChannelBuilder
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.*
import project.namjun.kim.robster.proto.RobsterGrpc
import project.namjun.kim.robster.proto.RobsterOuterClass

Expand All @@ -16,9 +14,14 @@ class AnalysisController {
@Autowired
lateinit var analysisService: AnalysisService

@GetMapping("/test")
fun testMethod(): String {
return analysisService.executeAnalysis()
@PostMapping("/")
fun requestAnalysis(@RequestBody analysisDTO: AnalysisDTO): AnalysisMapping {
var analysisResult: RobsterOuterClass.AnalysisResponse = analysisService.executeAnalysis(analysisDTO)
return AnalysisMapping(
id = analysisResult.id,
status = analysisResult.status,
message = analysisResult.message
)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package project.namjun.kim.robster.analysis

import com.fasterxml.jackson.annotation.JsonProperty

data class AnalysisDTO(
@JsonProperty("path")
var requestPath: String,

@JsonProperty("type")
var requestType: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package project.namjun.kim.robster.analysis

data class AnalysisMapping(
var id: String,
var status: Boolean,
var message: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Service
import project.namjun.kim.robster.proto.RobsterGrpc
import project.namjun.kim.robster.proto.RobsterOuterClass
import java.util.*

@Service
class AnalysisService {
Expand All @@ -14,20 +15,21 @@ class AnalysisService {

@Value("\${robster.analyzer.port}")
var analyzerPort: Int = 0
val uniqueId: String = UUID.randomUUID().toString()

fun executeAnalysis(): String {
fun executeAnalysis(analysisDTO: AnalysisDTO): RobsterOuterClass.AnalysisResponse {
var managedChannel: ManagedChannel = ManagedChannelBuilder.forAddress(
analyzerHost, analyzerPort
).usePlaintext().build()
var robsterStub: RobsterGrpc.RobsterBlockingStub = RobsterGrpc.newBlockingStub(managedChannel)
var analysisRequest: RobsterOuterClass.AnalysisRequest = RobsterOuterClass.AnalysisRequest.newBuilder()
.setId("id")
.setPath("D:\\dev\\ml-attacker\\binaries\\com.hyundaicard.appcard.apk")
.setType("apk")
.setId(uniqueId)
.setPath(analysisDTO.requestPath)
.setType(analysisDTO.requestType)
.build()

var analysisResponse: RobsterOuterClass.AnalysisResponse = robsterStub.executeAnalysis(analysisRequest)
managedChannel.shutdown()
return analysisResponse.message
return analysisResponse
}
}

0 comments on commit bc1dd45

Please sign in to comment.