-
Notifications
You must be signed in to change notification settings - Fork 317
Fix inaccessible fields capture #6883
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
Conversation
NoSuchFieldException can be thrown if we try to capture, through reflection, (static) fields from JDK classes or from another module. To fix this we need to catch eventual exception thrown by accessing field values. For that we continue to try to access directly to field when possible because it will be faster, but when we detect fields are not accessible we use another method that try to access it through reflection but could catch exception if not and returns a CapturedValue instance filled with the reason of this exception.
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 49 metrics, 14 unstable metrics. Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.32.0-SNAPSHOT~62a7002f0d, baseline=1.32.0-SNAPSHOT~396fccabad
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.081 s) : 0, 1081233
Total [baseline] (8.583 s) : 0, 8582527
Agent [candidate] (1.084 s) : 0, 1084011
Total [candidate] (8.567 s) : 0, 8567358
section iast
Agent [baseline] (1.215 s) : 0, 1214750
Total [baseline] (9.015 s) : 0, 9014676
Agent [candidate] (1.195 s) : 0, 1195028
Total [candidate] (9.009 s) : 0, 9009124
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.206 s) : 0, 1205744
Total [baseline] (8.975 s) : 0, 8975098
Agent [candidate] (1.215 s) : 0, 1214555
Total [candidate] (9.035 s) : 0, 9034784
section iast_TELEMETRY_OFF
Agent [baseline] (1.199 s) : 0, 1198706
Total [baseline] (9.038 s) : 0, 9037581
Agent [candidate] (1.2 s) : 0, 1199767
Total [candidate] (9.023 s) : 0, 9023292
gantt
title insecure-bank - break down per module: candidate=1.32.0-SNAPSHOT~62a7002f0d, baseline=1.32.0-SNAPSHOT~396fccabad
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (677.331 ms) : 0, 677331
BytebuddyAgent [candidate] (678.888 ms) : 0, 678888
GlobalTracer [baseline] (311.302 ms) : 0, 311302
GlobalTracer [candidate] (312.58 ms) : 0, 312580
AppSec [baseline] (49.752 ms) : 0, 49752
AppSec [candidate] (49.775 ms) : 0, 49775
Remote Config [baseline] (664.714 µs) : 0, 665
Remote Config [candidate] (668.272 µs) : 0, 668
Telemetry [baseline] (7.626 ms) : 0, 7626
Telemetry [candidate] (7.585 ms) : 0, 7585
section iast
BytebuddyAgent [baseline] (805.9 ms) : 0, 805900
BytebuddyAgent [candidate] (792.053 ms) : 0, 792053
GlobalTracer [baseline] (291.399 ms) : 0, 291399
GlobalTracer [candidate] (287.965 ms) : 0, 287965
AppSec [baseline] (50.919 ms) : 0, 50919
AppSec [candidate] (49.245 ms) : 0, 49245
IAST [baseline] (23.727 ms) : 0, 23727
IAST [candidate] (21.309 ms) : 0, 21309
Remote Config [baseline] (574.524 µs) : 0, 575
Remote Config [candidate] (581.48 µs) : 0, 581
Telemetry [baseline] (7.327 ms) : 0, 7327
Telemetry [candidate] (9.628 ms) : 0, 9628
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (799.316 ms) : 0, 799316
BytebuddyAgent [candidate] (805.843 ms) : 0, 805843
GlobalTracer [baseline] (289.363 ms) : 0, 289363
GlobalTracer [candidate] (292.302 ms) : 0, 292302
AppSec [baseline] (51.438 ms) : 0, 51438
AppSec [candidate] (50.529 ms) : 0, 50529
IAST [baseline] (22.961 ms) : 0, 22961
IAST [candidate] (23.061 ms) : 0, 23061
Remote Config [baseline] (593.888 µs) : 0, 594
Remote Config [candidate] (586.531 µs) : 0, 587
Telemetry [baseline] (7.493 ms) : 0, 7493
Telemetry [candidate] (7.359 ms) : 0, 7359
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (792.732 ms) : 0, 792732
BytebuddyAgent [candidate] (794.325 ms) : 0, 794325
GlobalTracer [baseline] (290.102 ms) : 0, 290102
GlobalTracer [candidate] (289.544 ms) : 0, 289544
AppSec [baseline] (49.682 ms) : 0, 49682
AppSec [candidate] (49.762 ms) : 0, 49762
IAST [baseline] (23.836 ms) : 0, 23836
IAST [candidate] (24.571 ms) : 0, 24571
Remote Config [baseline] (594.545 µs) : 0, 595
Remote Config [candidate] (579.927 µs) : 0, 580
Telemetry [baseline] (7.357 ms) : 0, 7357
Telemetry [candidate] (6.522 ms) : 0, 6522
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.32.0-SNAPSHOT~62a7002f0d, baseline=1.32.0-SNAPSHOT~396fccabad
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.075 s) : 0, 1074592
Total [baseline] (10.465 s) : 0, 10465478
Agent [candidate] (1.075 s) : 0, 1075173
Total [candidate] (10.342 s) : 0, 10342377
section appsec
Agent [baseline] (1.204 s) : 0, 1204160
Total [baseline] (10.504 s) : 0, 10503658
Agent [candidate] (1.2 s) : 0, 1200064
Total [candidate] (10.468 s) : 0, 10468449
section iast
Agent [baseline] (1.2 s) : 0, 1199826
Total [baseline] (10.798 s) : 0, 10797525
Agent [candidate] (1.198 s) : 0, 1198087
Total [candidate] (10.8 s) : 0, 10800158
section profiling
Agent [baseline] (1.274 s) : 0, 1274007
Total [baseline] (10.653 s) : 0, 10652979
Agent [candidate] (1.266 s) : 0, 1265675
Total [candidate] (10.589 s) : 0, 10588895
gantt
title petclinic - break down per module: candidate=1.32.0-SNAPSHOT~62a7002f0d, baseline=1.32.0-SNAPSHOT~396fccabad
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (672.642 ms) : 0, 672642
BytebuddyAgent [candidate] (672.968 ms) : 0, 672968
GlobalTracer [baseline] (309.623 ms) : 0, 309623
GlobalTracer [candidate] (310.02 ms) : 0, 310020
AppSec [baseline] (49.589 ms) : 0, 49589
AppSec [candidate] (49.588 ms) : 0, 49588
Remote Config [baseline] (660.836 µs) : 0, 661
Remote Config [candidate] (661.735 µs) : 0, 662
Telemetry [baseline] (7.634 ms) : 0, 7634
Telemetry [candidate] (7.584 ms) : 0, 7584
section appsec
BytebuddyAgent [baseline] (699.465 ms) : 0, 699465
BytebuddyAgent [candidate] (696.034 ms) : 0, 696034
GlobalTracer [baseline] (292.938 ms) : 0, 292938
GlobalTracer [candidate] (292.538 ms) : 0, 292538
AppSec [baseline] (150.099 ms) : 0, 150099
AppSec [candidate] (149.52 ms) : 0, 149520
Remote Config [baseline] (613.674 µs) : 0, 614
Remote Config [candidate] (603.504 µs) : 0, 604
Telemetry [baseline] (7.487 ms) : 0, 7487
Telemetry [candidate] (8.099 ms) : 0, 8099
IAST [baseline] (18.916 ms) : 0, 18916
IAST [candidate] (18.822 ms) : 0, 18822
section iast
BytebuddyAgent [baseline] (795.782 ms) : 0, 795782
BytebuddyAgent [candidate] (793.474 ms) : 0, 793474
GlobalTracer [baseline] (288.025 ms) : 0, 288025
GlobalTracer [candidate] (288.392 ms) : 0, 288392
AppSec [baseline] (50.216 ms) : 0, 50216
AppSec [candidate] (51.844 ms) : 0, 51844
Remote Config [baseline] (579.345 µs) : 0, 579
Remote Config [candidate] (580.856 µs) : 0, 581
Telemetry [baseline] (6.566 ms) : 0, 6566
Telemetry [candidate] (8.093 ms) : 0, 8093
IAST [baseline] (24.223 ms) : 0, 24223
IAST [candidate] (21.282 ms) : 0, 21282
section profiling
ProfilingAgent [baseline] (96.198 ms) : 0, 96198
ProfilingAgent [candidate] (95.482 ms) : 0, 95482
BytebuddyAgent [baseline] (680.892 ms) : 0, 680892
BytebuddyAgent [candidate] (675.639 ms) : 0, 675639
GlobalTracer [baseline] (381.755 ms) : 0, 381755
GlobalTracer [candidate] (380.384 ms) : 0, 380384
AppSec [baseline] (50.427 ms) : 0, 50427
AppSec [candidate] (49.92 ms) : 0, 49920
Remote Config [baseline] (706.726 µs) : 0, 707
Remote Config [candidate] (699.819 µs) : 0, 700
Telemetry [baseline] (7.464 ms) : 0, 7464
Telemetry [candidate] (7.441 ms) : 0, 7441
Profiling [baseline] (96.223 ms) : 0, 96223
Profiling [candidate] (95.506 ms) : 0, 95506
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 13 metrics, 15 unstable metrics. Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.32.0-SNAPSHOT~62a7002f0d, baseline=1.32.0-SNAPSHOT~396fccabad
dateFormat X
axisFormat %s
section baseline
no_agent (372.694 µs) : 353, 392
. : milestone, 373,
iast (479.76 µs) : 458, 501
. : milestone, 480,
iast_FULL (546.141 µs) : 525, 567
. : milestone, 546,
iast_GLOBAL (503.069 µs) : 481, 525
. : milestone, 503,
iast_HARDCODED_SECRET_DISABLED (483.553 µs) : 462, 506
. : milestone, 484,
iast_INACTIVE (447.59 µs) : 427, 468
. : milestone, 448,
iast_TELEMETRY_OFF (474.058 µs) : 453, 495
. : milestone, 474,
tracing (450.981 µs) : 431, 471
. : milestone, 451,
section candidate
no_agent (376.005 µs) : 356, 396
. : milestone, 376,
iast (475.927 µs) : 455, 497
. : milestone, 476,
iast_FULL (547.439 µs) : 526, 568
. : milestone, 547,
iast_GLOBAL (498.726 µs) : 477, 520
. : milestone, 499,
iast_HARDCODED_SECRET_DISABLED (492.775 µs) : 471, 514
. : milestone, 493,
iast_INACTIVE (449.953 µs) : 429, 471
. : milestone, 450,
iast_TELEMETRY_OFF (474.012 µs) : 454, 494
. : milestone, 474,
tracing (450.808 µs) : 430, 472
. : milestone, 451,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.32.0-SNAPSHOT~62a7002f0d, baseline=1.32.0-SNAPSHOT~396fccabad
dateFormat X
axisFormat %s
section baseline
no_agent (1.345 ms) : 1326, 1364
. : milestone, 1345,
appsec (1.734 ms) : 1710, 1757
. : milestone, 1734,
appsec_no_iast (1.725 ms) : 1701, 1750
. : milestone, 1725,
iast (1.503 ms) : 1480, 1526
. : milestone, 1503,
profiling (1.491 ms) : 1467, 1516
. : milestone, 1491,
tracing (1.48 ms) : 1455, 1504
. : milestone, 1480,
section candidate
no_agent (1.369 ms) : 1350, 1388
. : milestone, 1369,
appsec (1.713 ms) : 1689, 1738
. : milestone, 1713,
appsec_no_iast (1.716 ms) : 1691, 1740
. : milestone, 1716,
iast (1.505 ms) : 1482, 1528
. : milestone, 1505,
profiling (1.51 ms) : 1486, 1534
. : milestone, 1510,
tracing (1.499 ms) : 1474, 1525
. : milestone, 1499,
|
evanchooly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks good to me. a rather straightforward solution.
| int counter = 0; | ||
| for (FieldNode fieldNode : fieldsToCapture) { | ||
| insnList.add(new InsnNode(Opcodes.DUP)); | ||
| // stack: [capturedcontext, capturedcontext, array, array] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like the tracking of the stack values. :)
What Does This Do
To fix this we need to catch eventual exception thrown by accessing field values. For that we continue to try to access directly to field when possible because it will be faster, but when we detect fields are not accessible we use another method that try to access it through reflection but could catch exception if not and returns a CapturedValue instance filled with the reason of this exception.
Motivation
NoSuchFieldException can be thrown if we try to capture, through reflection, (static) fields from JDK classes or from another module.
Additional Notes
Jira ticket: DEBUG-2270