File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.utils.Ama
31
31
import software.aws.toolkits.jetbrains.services.codewhisperer.language.CodeWhispererProgrammingLanguage
32
32
import software.aws.toolkits.jetbrains.services.codewhisperer.language.languages.CodeWhispererUnknownLanguage
33
33
import software.aws.toolkits.jetbrains.services.codewhisperer.language.programmingLanguage
34
+ import software.aws.toolkits.jetbrains.services.codewhisperer.telemetry.CodeWhispererTelemetryService
34
35
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.CODE_SCAN_CREATE_PAYLOAD_TIMEOUT_IN_SECONDS
35
36
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.CodeAnalysisScope
36
37
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.DEFAULT_CODE_SCAN_TIMEOUT_IN_SECONDS
@@ -195,6 +196,9 @@ class CodeScanSessionConfig(
195
196
files.forEach { file ->
196
197
try {
197
198
val relativePath = " ${project.name} /${file.relativeTo(projectRoot.toNioPath())} "
199
+ if (relativePath.contains(" ../" ) || relativePath.contains(" ..\\ " )) {
200
+ CodeWhispererTelemetryService .getInstance().sendInvalidZipEvent(file, projectRoot.toNioPath(), relativePath)
201
+ }
198
202
LOG .debug { " Selected file for truncation: $file " }
199
203
it.putNextEntry(relativePath.toString(), file)
200
204
} catch (e: Exception ) {
Original file line number Diff line number Diff line change @@ -51,9 +51,11 @@ import software.aws.toolkits.telemetry.Component
51
51
import software.aws.toolkits.telemetry.CredentialSourceId
52
52
import software.aws.toolkits.telemetry.MetricResult
53
53
import software.aws.toolkits.telemetry.Result
54
+ import java.nio.file.Path
54
55
import java.time.Duration
55
56
import java.time.Instant
56
57
import java.util.Queue
58
+ import kotlin.io.path.pathString
57
59
58
60
@Service
59
61
class CodeWhispererTelemetryService {
@@ -609,6 +611,14 @@ class CodeWhispererTelemetryService {
609
611
assert (ApplicationManager .getApplication().isUnitTestMode)
610
612
return this .previousUserTriggerDecisions
611
613
}
614
+
615
+ fun sendInvalidZipEvent (filePath : Path , projectRoot : Path , relativePath : String ) {
616
+ CodewhispererTelemetry .invalidZip(
617
+ filePath = filePath.pathString,
618
+ workspaceRoot = projectRoot.pathString,
619
+ relativePath = relativePath
620
+ )
621
+ }
612
622
}
613
623
614
624
fun isTelemetryEnabled (): Boolean = AwsSettings .getInstance().isTelemetryEnabled
Original file line number Diff line number Diff line change 177
177
" reloaded"
178
178
],
179
179
"description" : " Toolkit run state."
180
+ },
181
+ {
182
+ "name" : " filePath" ,
183
+ "type" : " string" ,
184
+ "description" : " The path of the file"
185
+ },
186
+ {
187
+ "name" : " workspaceRoot" ,
188
+ "type" : " string" ,
189
+ "description" : " The path of the project root"
190
+ },
191
+ {
192
+ "name" : " relativePath" ,
193
+ "type" : " string" ,
194
+ "description" : " The relative path of the file"
180
195
}
181
196
],
182
197
"metrics" : [
530
545
}
531
546
],
532
547
"passive" : true
548
+ },
549
+ {
550
+ "name" : " codewhisperer_invalidZip" ,
551
+ "description" : " Invalid zip file" ,
552
+ "metadata" : [
553
+ {
554
+ "type" : " filePath" ,
555
+ "required" : true
556
+ },
557
+ {
558
+ "type" : " workspaceRoot" ,
559
+ "required" : true
560
+ },
561
+ {
562
+ "type" : " relativePath" ,
563
+ "required" : true
564
+ }
565
+ ]
533
566
}
534
567
]
535
568
}
You can’t perform that action at this time.
0 commit comments