inspec-core 6.8.24 → 7.0.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +8 -8
- data/etc/deprecations.json +42 -4
- data/inspec-core.gemspec +14 -7
- data/lib/inspec/archive/tar.rb +1 -0
- data/lib/inspec/backend.rb +2 -0
- data/lib/inspec/base_cli.rb +15 -2
- data/lib/inspec/cached_fetcher.rb +17 -1
- data/lib/inspec/cli.rb +2 -0
- data/lib/inspec/dependencies/cache.rb +47 -7
- data/lib/inspec/dsl.rb +44 -10
- data/lib/inspec/exceptions.rb +1 -0
- data/lib/inspec/fetcher/gem.rb +117 -0
- data/lib/inspec/fetcher/git.rb +21 -1
- data/lib/inspec/fetcher/local.rb +1 -1
- data/lib/inspec/fetcher.rb +1 -0
- data/lib/inspec/file_provider.rb +47 -1
- data/lib/inspec/metadata.rb +2 -0
- data/lib/inspec/plugin/v2/concerns/gem_spec_helper.rb +30 -0
- data/lib/inspec/plugin/v2/gem_source_manager.rb +50 -0
- data/lib/inspec/plugin/v2/installer.rb +65 -18
- data/lib/inspec/plugin/v2/loader.rb +37 -6
- data/lib/inspec/plugin/v2/plugin_types/resource_pack.rb +8 -0
- data/lib/inspec/plugin/v2.rb +1 -0
- data/lib/inspec/profile.rb +22 -3
- data/lib/inspec/profile_context.rb +10 -0
- data/lib/inspec/resources/audit_policy.rb +8 -2
- data/lib/inspec/resources/groups.rb +52 -0
- data/lib/inspec/resources.rb +0 -14
- data/lib/inspec/rule.rb +2 -0
- data/lib/inspec/runner.rb +7 -1
- data/lib/inspec/source_reader.rb +2 -0
- data/lib/inspec/ui.rb +1 -0
- data/lib/inspec/utils/deprecated_core_resources_list.rb +2 -2
- data/lib/inspec/utils/deprecation/config_file.rb +39 -3
- data/lib/inspec/utils/deprecation/deprecator.rb +10 -3
- data/lib/inspec/utils/simpleconfig.rb +2 -0
- data/lib/inspec/utils/telemetry/run_context_probe.rb +5 -2
- data/lib/inspec/version.rb +1 -1
- data/lib/inspec/waiver_file_reader.rb +35 -18
- data/lib/inspec.rb +2 -0
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +1 -1
- data/lib/plugins/shared/core_plugin_test_helper.rb +1 -1
- data/lib/source_readers/gem.rb +67 -0
- metadata +82 -43
- data/lib/inspec/resources/docker.rb +0 -274
- data/lib/inspec/resources/docker_container.rb +0 -116
- data/lib/inspec/resources/docker_image.rb +0 -141
- data/lib/inspec/resources/docker_object.rb +0 -52
- data/lib/inspec/resources/docker_plugin.rb +0 -68
- data/lib/inspec/resources/docker_service.rb +0 -95
- data/lib/inspec/resources/elasticsearch.rb +0 -165
- data/lib/inspec/resources/ibmdb2_conf.rb +0 -65
- data/lib/inspec/resources/ibmdb2_session.rb +0 -78
- data/lib/inspec/resources/mongodb.rb +0 -69
- data/lib/inspec/resources/mongodb_conf.rb +0 -44
- data/lib/inspec/resources/mongodb_session.rb +0 -98
- data/lib/inspec/resources/opa.rb +0 -26
- data/lib/inspec/resources/opa_api.rb +0 -49
- data/lib/inspec/resources/opa_cli.rb +0 -57
- data/lib/inspec/resources/podman.rb +0 -353
- data/lib/inspec/resources/podman_container.rb +0 -84
- data/lib/inspec/resources/podman_image.rb +0 -108
- data/lib/inspec/resources/podman_network.rb +0 -81
- data/lib/inspec/resources/podman_pod.rb +0 -101
- data/lib/inspec/resources/podman_volume.rb +0 -87
- data/lib/inspec/resources/rabbitmq_conf.rb +0 -2
- data/lib/inspec/resources/rabbitmq_config.rb +0 -56
- data/lib/inspec/resources/sybase_conf.rb +0 -41
- data/lib/inspec/resources/sybase_session.rb +0 -124
- data/lib/inspec/utils/podman.rb +0 -24
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inspec-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 7.0.95
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chef InSpec Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-10-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: chef-telemetry
|
|
@@ -59,7 +59,7 @@ dependencies:
|
|
|
59
59
|
version: '0.20'
|
|
60
60
|
- - "<"
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: 1.
|
|
62
|
+
version: 1.5.0
|
|
63
63
|
type: :runtime
|
|
64
64
|
prerelease: false
|
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -69,7 +69,7 @@ dependencies:
|
|
|
69
69
|
version: '0.20'
|
|
70
70
|
- - "<"
|
|
71
71
|
- !ruby/object:Gem::Version
|
|
72
|
-
version: 1.
|
|
72
|
+
version: 1.5.0
|
|
73
73
|
- !ruby/object:Gem::Dependency
|
|
74
74
|
name: method_source
|
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -99,7 +99,7 @@ dependencies:
|
|
|
99
99
|
version: 1.2.2
|
|
100
100
|
- - "<"
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '
|
|
102
|
+
version: '4.0'
|
|
103
103
|
type: :runtime
|
|
104
104
|
prerelease: false
|
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -109,7 +109,7 @@ dependencies:
|
|
|
109
109
|
version: 1.2.2
|
|
110
110
|
- - "<"
|
|
111
111
|
- !ruby/object:Gem::Version
|
|
112
|
-
version: '
|
|
112
|
+
version: '4.0'
|
|
113
113
|
- !ruby/object:Gem::Dependency
|
|
114
114
|
name: rspec
|
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -134,16 +134,22 @@ dependencies:
|
|
|
134
134
|
name: rspec-its
|
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
|
136
136
|
requirements:
|
|
137
|
-
- - "
|
|
137
|
+
- - ">="
|
|
138
138
|
- !ruby/object:Gem::Version
|
|
139
139
|
version: '1.2'
|
|
140
|
+
- - "<"
|
|
141
|
+
- !ruby/object:Gem::Version
|
|
142
|
+
version: '3.0'
|
|
140
143
|
type: :runtime
|
|
141
144
|
prerelease: false
|
|
142
145
|
version_requirements: !ruby/object:Gem::Requirement
|
|
143
146
|
requirements:
|
|
144
|
-
- - "
|
|
147
|
+
- - ">="
|
|
145
148
|
- !ruby/object:Gem::Version
|
|
146
149
|
version: '1.2'
|
|
150
|
+
- - "<"
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '3.0'
|
|
147
153
|
- !ruby/object:Gem::Dependency
|
|
148
154
|
name: pry
|
|
149
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -288,7 +294,7 @@ dependencies:
|
|
|
288
294
|
requirements:
|
|
289
295
|
- - ">="
|
|
290
296
|
- !ruby/object:Gem::Version
|
|
291
|
-
version: '1.
|
|
297
|
+
version: '1.3'
|
|
292
298
|
- - "<"
|
|
293
299
|
- !ruby/object:Gem::Version
|
|
294
300
|
version: '2.1'
|
|
@@ -298,7 +304,7 @@ dependencies:
|
|
|
298
304
|
requirements:
|
|
299
305
|
- - ">="
|
|
300
306
|
- !ruby/object:Gem::Version
|
|
301
|
-
version: '1.
|
|
307
|
+
version: '1.3'
|
|
302
308
|
- - "<"
|
|
303
309
|
- !ruby/object:Gem::Version
|
|
304
310
|
version: '2.1'
|
|
@@ -325,7 +331,7 @@ dependencies:
|
|
|
325
331
|
version: '1.5'
|
|
326
332
|
- - "<"
|
|
327
333
|
- !ruby/object:Gem::Version
|
|
328
|
-
version: '
|
|
334
|
+
version: '3.0'
|
|
329
335
|
type: :runtime
|
|
330
336
|
prerelease: false
|
|
331
337
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -335,7 +341,7 @@ dependencies:
|
|
|
335
341
|
version: '1.5'
|
|
336
342
|
- - "<"
|
|
337
343
|
- !ruby/object:Gem::Version
|
|
338
|
-
version: '
|
|
344
|
+
version: '3.0'
|
|
339
345
|
- !ruby/object:Gem::Dependency
|
|
340
346
|
name: semverse
|
|
341
347
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -364,6 +370,54 @@ dependencies:
|
|
|
364
370
|
- - "~>"
|
|
365
371
|
- !ruby/object:Gem::Version
|
|
366
372
|
version: '2.0'
|
|
373
|
+
- !ruby/object:Gem::Dependency
|
|
374
|
+
name: syslog
|
|
375
|
+
requirement: !ruby/object:Gem::Requirement
|
|
376
|
+
requirements:
|
|
377
|
+
- - "~>"
|
|
378
|
+
- !ruby/object:Gem::Version
|
|
379
|
+
version: '0.1'
|
|
380
|
+
type: :runtime
|
|
381
|
+
prerelease: false
|
|
382
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
383
|
+
requirements:
|
|
384
|
+
- - "~>"
|
|
385
|
+
- !ruby/object:Gem::Version
|
|
386
|
+
version: '0.1'
|
|
387
|
+
- !ruby/object:Gem::Dependency
|
|
388
|
+
name: csv
|
|
389
|
+
requirement: !ruby/object:Gem::Requirement
|
|
390
|
+
requirements:
|
|
391
|
+
- - "~>"
|
|
392
|
+
- !ruby/object:Gem::Version
|
|
393
|
+
version: '3.0'
|
|
394
|
+
type: :runtime
|
|
395
|
+
prerelease: false
|
|
396
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
397
|
+
requirements:
|
|
398
|
+
- - "~>"
|
|
399
|
+
- !ruby/object:Gem::Version
|
|
400
|
+
version: '3.0'
|
|
401
|
+
- !ruby/object:Gem::Dependency
|
|
402
|
+
name: ostruct
|
|
403
|
+
requirement: !ruby/object:Gem::Requirement
|
|
404
|
+
requirements:
|
|
405
|
+
- - ">="
|
|
406
|
+
- !ruby/object:Gem::Version
|
|
407
|
+
version: '0.1'
|
|
408
|
+
- - "<"
|
|
409
|
+
- !ruby/object:Gem::Version
|
|
410
|
+
version: '0.7'
|
|
411
|
+
type: :runtime
|
|
412
|
+
prerelease: false
|
|
413
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
414
|
+
requirements:
|
|
415
|
+
- - ">="
|
|
416
|
+
- !ruby/object:Gem::Version
|
|
417
|
+
version: '0.1'
|
|
418
|
+
- - "<"
|
|
419
|
+
- !ruby/object:Gem::Version
|
|
420
|
+
version: '0.7'
|
|
367
421
|
- !ruby/object:Gem::Dependency
|
|
368
422
|
name: cookstyle
|
|
369
423
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -382,30 +436,36 @@ dependencies:
|
|
|
382
436
|
name: train-core
|
|
383
437
|
requirement: !ruby/object:Gem::Requirement
|
|
384
438
|
requirements:
|
|
439
|
+
- - "~>"
|
|
440
|
+
- !ruby/object:Gem::Version
|
|
441
|
+
version: '3.13'
|
|
385
442
|
- - ">="
|
|
386
443
|
- !ruby/object:Gem::Version
|
|
387
|
-
version: 3.
|
|
444
|
+
version: 3.13.4
|
|
388
445
|
type: :runtime
|
|
389
446
|
prerelease: false
|
|
390
447
|
version_requirements: !ruby/object:Gem::Requirement
|
|
391
448
|
requirements:
|
|
449
|
+
- - "~>"
|
|
450
|
+
- !ruby/object:Gem::Version
|
|
451
|
+
version: '3.13'
|
|
392
452
|
- - ">="
|
|
393
453
|
- !ruby/object:Gem::Version
|
|
394
|
-
version: 3.
|
|
454
|
+
version: 3.13.4
|
|
395
455
|
- !ruby/object:Gem::Dependency
|
|
396
456
|
name: chef-licensing
|
|
397
457
|
requirement: !ruby/object:Gem::Requirement
|
|
398
458
|
requirements:
|
|
399
459
|
- - ">="
|
|
400
460
|
- !ruby/object:Gem::Version
|
|
401
|
-
version: 1.0
|
|
461
|
+
version: 1.2.0
|
|
402
462
|
type: :runtime
|
|
403
463
|
prerelease: false
|
|
404
464
|
version_requirements: !ruby/object:Gem::Requirement
|
|
405
465
|
requirements:
|
|
406
466
|
- - ">="
|
|
407
467
|
- !ruby/object:Gem::Version
|
|
408
|
-
version: 1.0
|
|
468
|
+
version: 1.2.0
|
|
409
469
|
description: |+
|
|
410
470
|
InSpec provides a framework for creating end-to-end infrastructure tests. You can use it for integration or even compliance testing. Create fully portable test profiles and use them in your workflow to ensure stability and security. Integrate InSpec in your change lifecycle for local testing, CI/CD, and deployment verification.
|
|
411
471
|
This has local support only. See the `inspec` gem for full support.
|
|
@@ -472,6 +532,7 @@ files:
|
|
|
472
532
|
- lib/inspec/feature/config.rb
|
|
473
533
|
- lib/inspec/feature/runner.rb
|
|
474
534
|
- lib/inspec/fetcher.rb
|
|
535
|
+
- lib/inspec/fetcher/gem.rb
|
|
475
536
|
- lib/inspec/fetcher/git.rb
|
|
476
537
|
- lib/inspec/fetcher/local.rb
|
|
477
538
|
- lib/inspec/fetcher/mock.rb
|
|
@@ -511,8 +572,10 @@ files:
|
|
|
511
572
|
- lib/inspec/plugin/v1/registry.rb
|
|
512
573
|
- lib/inspec/plugin/v2.rb
|
|
513
574
|
- lib/inspec/plugin/v2/activator.rb
|
|
575
|
+
- lib/inspec/plugin/v2/concerns/gem_spec_helper.rb
|
|
514
576
|
- lib/inspec/plugin/v2/config_file.rb
|
|
515
577
|
- lib/inspec/plugin/v2/filter.rb
|
|
578
|
+
- lib/inspec/plugin/v2/gem_source_manager.rb
|
|
516
579
|
- lib/inspec/plugin/v2/installer.rb
|
|
517
580
|
- lib/inspec/plugin/v2/loader.rb
|
|
518
581
|
- lib/inspec/plugin/v2/plugin_base.rb
|
|
@@ -521,6 +584,7 @@ files:
|
|
|
521
584
|
- lib/inspec/plugin/v2/plugin_types/input.rb
|
|
522
585
|
- lib/inspec/plugin/v2/plugin_types/mock.rb
|
|
523
586
|
- lib/inspec/plugin/v2/plugin_types/reporter.rb
|
|
587
|
+
- lib/inspec/plugin/v2/plugin_types/resource_pack.rb
|
|
524
588
|
- lib/inspec/plugin/v2/plugin_types/streaming_reporter.rb
|
|
525
589
|
- lib/inspec/plugin/v2/registry.rb
|
|
526
590
|
- lib/inspec/plugin/v2/status.rb
|
|
@@ -563,13 +627,6 @@ files:
|
|
|
563
627
|
- lib/inspec/resources/default_gateway.rb
|
|
564
628
|
- lib/inspec/resources/dh_params.rb
|
|
565
629
|
- lib/inspec/resources/directory.rb
|
|
566
|
-
- lib/inspec/resources/docker.rb
|
|
567
|
-
- lib/inspec/resources/docker_container.rb
|
|
568
|
-
- lib/inspec/resources/docker_image.rb
|
|
569
|
-
- lib/inspec/resources/docker_object.rb
|
|
570
|
-
- lib/inspec/resources/docker_plugin.rb
|
|
571
|
-
- lib/inspec/resources/docker_service.rb
|
|
572
|
-
- lib/inspec/resources/elasticsearch.rb
|
|
573
630
|
- lib/inspec/resources/etc_fstab.rb
|
|
574
631
|
- lib/inspec/resources/etc_group.rb
|
|
575
632
|
- lib/inspec/resources/etc_hosts.rb
|
|
@@ -585,8 +642,6 @@ files:
|
|
|
585
642
|
- lib/inspec/resources/grub_conf.rb
|
|
586
643
|
- lib/inspec/resources/host.rb
|
|
587
644
|
- lib/inspec/resources/http.rb
|
|
588
|
-
- lib/inspec/resources/ibmdb2_conf.rb
|
|
589
|
-
- lib/inspec/resources/ibmdb2_session.rb
|
|
590
645
|
- lib/inspec/resources/iis_app.rb
|
|
591
646
|
- lib/inspec/resources/iis_app_pool.rb
|
|
592
647
|
- lib/inspec/resources/iis_site.rb
|
|
@@ -612,9 +667,6 @@ files:
|
|
|
612
667
|
- lib/inspec/resources/login_defs.rb
|
|
613
668
|
- lib/inspec/resources/lxc.rb
|
|
614
669
|
- lib/inspec/resources/mail_alias.rb
|
|
615
|
-
- lib/inspec/resources/mongodb.rb
|
|
616
|
-
- lib/inspec/resources/mongodb_conf.rb
|
|
617
|
-
- lib/inspec/resources/mongodb_session.rb
|
|
618
670
|
- lib/inspec/resources/mount.rb
|
|
619
671
|
- lib/inspec/resources/mssql_session.rb
|
|
620
672
|
- lib/inspec/resources/mssql_sys_conf.rb
|
|
@@ -628,9 +680,6 @@ files:
|
|
|
628
680
|
- lib/inspec/resources/npm.rb
|
|
629
681
|
- lib/inspec/resources/ntp_conf.rb
|
|
630
682
|
- lib/inspec/resources/oneget.rb
|
|
631
|
-
- lib/inspec/resources/opa.rb
|
|
632
|
-
- lib/inspec/resources/opa_api.rb
|
|
633
|
-
- lib/inspec/resources/opa_cli.rb
|
|
634
683
|
- lib/inspec/resources/oracle.rb
|
|
635
684
|
- lib/inspec/resources/oracledb_conf.rb
|
|
636
685
|
- lib/inspec/resources/oracledb_listener_conf.rb
|
|
@@ -645,12 +694,6 @@ files:
|
|
|
645
694
|
- lib/inspec/resources/php_config.rb
|
|
646
695
|
- lib/inspec/resources/pip.rb
|
|
647
696
|
- lib/inspec/resources/platform.rb
|
|
648
|
-
- lib/inspec/resources/podman.rb
|
|
649
|
-
- lib/inspec/resources/podman_container.rb
|
|
650
|
-
- lib/inspec/resources/podman_image.rb
|
|
651
|
-
- lib/inspec/resources/podman_network.rb
|
|
652
|
-
- lib/inspec/resources/podman_pod.rb
|
|
653
|
-
- lib/inspec/resources/podman_volume.rb
|
|
654
697
|
- lib/inspec/resources/port.rb
|
|
655
698
|
- lib/inspec/resources/postfix_conf.rb
|
|
656
699
|
- lib/inspec/resources/postgres.rb
|
|
@@ -661,8 +704,6 @@ files:
|
|
|
661
704
|
- lib/inspec/resources/powershell.rb
|
|
662
705
|
- lib/inspec/resources/ppa.rb
|
|
663
706
|
- lib/inspec/resources/processes.rb
|
|
664
|
-
- lib/inspec/resources/rabbitmq_conf.rb
|
|
665
|
-
- lib/inspec/resources/rabbitmq_config.rb
|
|
666
707
|
- lib/inspec/resources/registry_key.rb
|
|
667
708
|
- lib/inspec/resources/routing_table.rb
|
|
668
709
|
- lib/inspec/resources/runit_service.rb
|
|
@@ -677,8 +718,6 @@ files:
|
|
|
677
718
|
- lib/inspec/resources/sshd_active_config.rb
|
|
678
719
|
- lib/inspec/resources/sshd_config.rb
|
|
679
720
|
- lib/inspec/resources/ssl.rb
|
|
680
|
-
- lib/inspec/resources/sybase_conf.rb
|
|
681
|
-
- lib/inspec/resources/sybase_session.rb
|
|
682
721
|
- lib/inspec/resources/sys_info.rb
|
|
683
722
|
- lib/inspec/resources/systemd_service.rb
|
|
684
723
|
- lib/inspec/resources/sysv_service.rb
|
|
@@ -756,7 +795,6 @@ files:
|
|
|
756
795
|
- lib/inspec/utils/object_traversal.rb
|
|
757
796
|
- lib/inspec/utils/parser.rb
|
|
758
797
|
- lib/inspec/utils/pkey_reader.rb
|
|
759
|
-
- lib/inspec/utils/podman.rb
|
|
760
798
|
- lib/inspec/utils/profile_ast_helpers.rb
|
|
761
799
|
- lib/inspec/utils/run_data_filters.rb
|
|
762
800
|
- lib/inspec/utils/simpleconfig.rb
|
|
@@ -891,6 +929,7 @@ files:
|
|
|
891
929
|
- lib/plugins/shared/core_plugin_test_helper.rb
|
|
892
930
|
- lib/plugins/things-for-train-integration.rb
|
|
893
931
|
- lib/source_readers/flat.rb
|
|
932
|
+
- lib/source_readers/gem.rb
|
|
894
933
|
- lib/source_readers/inspec.rb
|
|
895
934
|
homepage: https://github.com/inspec/inspec
|
|
896
935
|
licenses:
|
|
@@ -911,7 +950,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
911
950
|
- !ruby/object:Gem::Version
|
|
912
951
|
version: '0'
|
|
913
952
|
requirements: []
|
|
914
|
-
rubygems_version: 3.
|
|
953
|
+
rubygems_version: 3.3.27
|
|
915
954
|
signing_key:
|
|
916
955
|
specification_version: 4
|
|
917
956
|
summary: Infrastructure and compliance testing. Core library.
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Copyright 2017, Christoph Hartmann
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
require "inspec/resources/command"
|
|
6
|
-
require "inspec/utils/filter"
|
|
7
|
-
require "hashie/mash"
|
|
8
|
-
|
|
9
|
-
module Inspec::Resources
|
|
10
|
-
class DockerContainerFilter
|
|
11
|
-
# use filtertable for containers
|
|
12
|
-
filter = FilterTable.create
|
|
13
|
-
filter.register_custom_matcher(:exists?) { |x| !x.entries.empty? }
|
|
14
|
-
filter.register_column(:commands, field: "command")
|
|
15
|
-
.register_column(:ids, field: "id")
|
|
16
|
-
.register_column(:images, field: "image")
|
|
17
|
-
.register_column(:labels, field: "labels", style: :simple)
|
|
18
|
-
.register_column(:local_volumes, field: "localvolumes")
|
|
19
|
-
.register_column(:mounts, field: "mounts")
|
|
20
|
-
.register_column(:names, field: "names")
|
|
21
|
-
.register_column(:networks, field: "networks")
|
|
22
|
-
.register_column(:ports, field: "ports")
|
|
23
|
-
.register_column(:running_for, field: "runningfor")
|
|
24
|
-
.register_column(:sizes, field: "size")
|
|
25
|
-
.register_column(:status, field: "status")
|
|
26
|
-
.register_custom_matcher(:running?) do |x|
|
|
27
|
-
x.where { status.downcase.start_with?("up") }
|
|
28
|
-
end
|
|
29
|
-
filter.install_filter_methods_on_resource(self, :containers)
|
|
30
|
-
|
|
31
|
-
attr_reader :containers
|
|
32
|
-
def initialize(containers)
|
|
33
|
-
@containers = containers
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
class DockerImageFilter
|
|
38
|
-
filter = FilterTable.create
|
|
39
|
-
filter.register_custom_matcher(:exists?) { |x| !x.entries.empty? }
|
|
40
|
-
filter.register_column(:ids, field: "id")
|
|
41
|
-
.register_column(:repositories, field: "repository")
|
|
42
|
-
.register_column(:tags, field: "tag")
|
|
43
|
-
.register_column(:sizes, field: "size")
|
|
44
|
-
.register_column(:digests, field: "digest")
|
|
45
|
-
.register_column(:created, field: "createdat")
|
|
46
|
-
.register_column(:created_since, field: "createdsize")
|
|
47
|
-
filter.install_filter_methods_on_resource(self, :images)
|
|
48
|
-
|
|
49
|
-
attr_reader :images
|
|
50
|
-
def initialize(images)
|
|
51
|
-
@images = images
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
class DockerPluginFilter
|
|
56
|
-
filter = FilterTable.create
|
|
57
|
-
filter.add(:ids, field: "id")
|
|
58
|
-
.add(:names, field: "name")
|
|
59
|
-
.add(:versions, field: "version")
|
|
60
|
-
.add(:enabled, field: "enabled")
|
|
61
|
-
filter.connect(self, :plugins)
|
|
62
|
-
|
|
63
|
-
attr_reader :plugins
|
|
64
|
-
def initialize(plugins)
|
|
65
|
-
@plugins = plugins
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
class DockerServiceFilter
|
|
70
|
-
filter = FilterTable.create
|
|
71
|
-
filter.register_custom_matcher(:exists?) { |x| !x.entries.empty? }
|
|
72
|
-
filter.register_column(:ids, field: "id")
|
|
73
|
-
.register_column(:names, field: "name")
|
|
74
|
-
.register_column(:modes, field: "mode")
|
|
75
|
-
.register_column(:replicas, field: "replicas")
|
|
76
|
-
.register_column(:images, field: "image")
|
|
77
|
-
.register_column(:ports, field: "ports")
|
|
78
|
-
filter.install_filter_methods_on_resource(self, :services)
|
|
79
|
-
|
|
80
|
-
attr_reader :services
|
|
81
|
-
def initialize(services)
|
|
82
|
-
@services = services
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# This resource helps to parse information from the docker host
|
|
87
|
-
# For compatability with Serverspec we also offer the following resouses:
|
|
88
|
-
# - docker_container
|
|
89
|
-
# - docker_image
|
|
90
|
-
class Docker < Inspec.resource(1)
|
|
91
|
-
name "docker"
|
|
92
|
-
supports platform: "unix"
|
|
93
|
-
desc "
|
|
94
|
-
A resource to retrieve information about docker
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
example <<~EXAMPLE
|
|
98
|
-
describe docker.containers do
|
|
99
|
-
its('images') { should_not include 'u12:latest' }
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
describe docker.images do
|
|
103
|
-
its('repositories') { should_not include 'inssecure_image' }
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
describe docker.plugins.where { name == 'rexray/ebs' } do
|
|
107
|
-
it { should exist }
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
describe docker.services do
|
|
111
|
-
its('images') { should_not include 'inssecure_image' }
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
describe docker.version do
|
|
115
|
-
its('Server.Version') { should cmp >= '1.12'}
|
|
116
|
-
its('Client.Version') { should cmp >= '1.12'}
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
describe docker.object(id) do
|
|
120
|
-
its('Configuration.Path') { should eq 'value' }
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
docker.containers.ids.each do |id|
|
|
124
|
-
# call docker inspect for a specific container id
|
|
125
|
-
describe docker.object(id) do
|
|
126
|
-
its(%w(HostConfig Privileged)) { should cmp false }
|
|
127
|
-
its(%w(HostConfig Privileged)) { should_not cmp true }
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
EXAMPLE
|
|
131
|
-
|
|
132
|
-
def containers
|
|
133
|
-
DockerContainerFilter.new(parse_containers)
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def images
|
|
137
|
-
DockerImageFilter.new(parse_images)
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def plugins
|
|
141
|
-
DockerPluginFilter.new(parse_plugins)
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
def services
|
|
145
|
-
DockerServiceFilter.new(parse_services)
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def version
|
|
149
|
-
return @version if defined?(@version)
|
|
150
|
-
|
|
151
|
-
data = {}
|
|
152
|
-
cmd = inspec.command("docker version --format '{{ json . }}'")
|
|
153
|
-
data = JSON.parse(cmd.stdout) if cmd.exit_status == 0
|
|
154
|
-
@version = Hashie::Mash.new(data)
|
|
155
|
-
rescue JSON::ParserError => _e
|
|
156
|
-
Hashie::Mash.new({})
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def info
|
|
160
|
-
return @info if defined?(@info)
|
|
161
|
-
|
|
162
|
-
data = {}
|
|
163
|
-
# docke info format is only supported for Docker 17.03+
|
|
164
|
-
cmd = inspec.command("docker info --format '{{ json . }}'")
|
|
165
|
-
data = JSON.parse(cmd.stdout) if cmd.exit_status == 0
|
|
166
|
-
@info = Hashie::Mash.new(data)
|
|
167
|
-
rescue JSON::ParserError => _e
|
|
168
|
-
Hashie::Mash.new({})
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
# returns information about docker objects
|
|
172
|
-
def object(id)
|
|
173
|
-
return @inspect if defined?(@inspect)
|
|
174
|
-
|
|
175
|
-
data = JSON.parse(inspec.command("docker inspect #{id}").stdout)
|
|
176
|
-
data = data[0] if data.is_a?(Array)
|
|
177
|
-
@inspect = Hashie::Mash.new(data)
|
|
178
|
-
rescue JSON::ParserError => _e
|
|
179
|
-
Hashie::Mash.new({})
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
def to_s
|
|
183
|
-
"Docker Host"
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
private
|
|
187
|
-
|
|
188
|
-
def parse_json_command(labels, subcommand)
|
|
189
|
-
# build command
|
|
190
|
-
format = labels.map { |label| "\"#{label}\": {{json .#{label}}}" }
|
|
191
|
-
raw = inspec.command("docker #{subcommand} --format '{#{format.join(", ")}}'").stdout
|
|
192
|
-
output = []
|
|
193
|
-
# since docker is not outputting valid json, we need to parse each row
|
|
194
|
-
raw.each_line do |entry|
|
|
195
|
-
# convert all keys to lower_case to work well with ruby and filter table
|
|
196
|
-
row = JSON.parse(entry).map do |key, value|
|
|
197
|
-
[key.downcase, value]
|
|
198
|
-
end.to_h
|
|
199
|
-
|
|
200
|
-
# ensure all keys are there
|
|
201
|
-
row = ensure_keys(row, labels)
|
|
202
|
-
|
|
203
|
-
# strip off any linked container names
|
|
204
|
-
# Depending on how it was linked, the actual container name may come before
|
|
205
|
-
# or after the link information, so we'll just look for the first name that
|
|
206
|
-
# does not include a slash since that is not a valid character in a container name
|
|
207
|
-
if row["names"]
|
|
208
|
-
row["names"] = row["names"].split(",").find { |c| !c.include?("/") }
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
# Split labels on ',' or set to empty array
|
|
212
|
-
# Allows for `docker.containers.where { labels.include?('app=redis') }`
|
|
213
|
-
row["labels"] = row.key?("labels") ? row["labels"].split(",") : []
|
|
214
|
-
|
|
215
|
-
output.push(row)
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
output
|
|
219
|
-
rescue JSON::ParserError => _e
|
|
220
|
-
warn "Could not parse `docker #{subcommand}` output"
|
|
221
|
-
[]
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
def parse_containers
|
|
225
|
-
# @see https://github.com/moby/moby/issues/20625, works for docker 1.13+
|
|
226
|
-
# raw_containers = inspec.command('docker ps -a --no-trunc --format \'{{ json . }}\'').stdout
|
|
227
|
-
# therefore we stick with older approach
|
|
228
|
-
labels = %w{Command CreatedAt ID Image Labels Mounts Names Ports RunningFor Size Status}
|
|
229
|
-
|
|
230
|
-
# Networks LocalVolumes work with 1.13+ only
|
|
231
|
-
if !version.empty? && Gem::Version.new(version["Client"]["Version"]) >= Gem::Version.new("1.13")
|
|
232
|
-
labels.push("Networks")
|
|
233
|
-
labels.push("LocalVolumes")
|
|
234
|
-
end
|
|
235
|
-
parse_json_command(labels, "ps -a --no-trunc")
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
def parse_services
|
|
239
|
-
parse_json_command(%w{ID Name Mode Replicas Image Ports}, "service ls")
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
def ensure_keys(entry, labels)
|
|
243
|
-
labels.each do |key|
|
|
244
|
-
entry[key.downcase] = nil unless entry.key?(key.downcase)
|
|
245
|
-
end
|
|
246
|
-
entry
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
def parse_images
|
|
250
|
-
# docker does not support the `json .` function here, therefore we need to emulate that behavior.
|
|
251
|
-
raw_images = inspec.command('docker images -a --no-trunc --format \'{ "id": {{json .ID}}, "repository": {{json .Repository}}, "tag": {{json .Tag}}, "size": {{json .Size}}, "digest": {{json .Digest}}, "createdat": {{json .CreatedAt}}, "createdsize": {{json .CreatedSince}} }\'').stdout
|
|
252
|
-
c_images = []
|
|
253
|
-
raw_images.each_line do |entry|
|
|
254
|
-
c_images.push(JSON.parse(entry))
|
|
255
|
-
end
|
|
256
|
-
c_images
|
|
257
|
-
rescue JSON::ParserError => _e
|
|
258
|
-
warn "Could not parse `docker images` output"
|
|
259
|
-
[]
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
def parse_plugins
|
|
263
|
-
plugins = inspec.command('docker plugin ls --format \'{"id": {{json .ID}}, "name": "{{ with split .Name ":"}}{{index . 0}}{{end}}", "version": "{{ with split .Name ":"}}{{index . 1}}{{end}}", "enabled": {{json .Enabled}} }\'').stdout
|
|
264
|
-
c_plugins = []
|
|
265
|
-
plugins.each_line do |entry|
|
|
266
|
-
c_plugins.push(JSON.parse(entry))
|
|
267
|
-
end
|
|
268
|
-
c_plugins
|
|
269
|
-
rescue JSON::ParserError => _e
|
|
270
|
-
warn "Could not parse `docker plugin ls` output"
|
|
271
|
-
[]
|
|
272
|
-
end
|
|
273
|
-
end
|
|
274
|
-
end
|