@dxworks/insider 2.9.1
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.
- package/.github/workflows/build.yml +19 -0
- package/.github/workflows/release-docs.yml +15 -0
- package/.github/workflows/release-voyager.yml +57 -0
- package/.github/workflows/release.yml +102 -0
- package/Dockerfile +8 -0
- package/README.md +89 -0
- package/TODO.txt +7 -0
- package/bin/insider.bat +1 -0
- package/bin/insider.sh +1 -0
- package/build.gradle +55 -0
- package/config/.ignore +4 -0
- package/config/comments.json +71 -0
- package/config/fingerprints/_anomalies-full.json +116 -0
- package/config/fingerprints/_extLibs.json +2555 -0
- package/config/fingerprints/code_smells.json +94 -0
- package/config/fingerprints/generated_code.json +17 -0
- package/config/fingerprints/libraries.json +4667 -0
- package/config/ignoredImports.txt +0 -0
- package/config/insider-conf.properties +3 -0
- package/config/rules/cloud_services/ad_networks.json +50 -0
- package/config/rules/cloud_services/bigdata.json +21 -0
- package/config/rules/cloud_services/cloud_hosting.json +398 -0
- package/config/rules/cloud_services/data_storage.json +291 -0
- package/config/rules/cloud_services/ecommerce.json +45 -0
- package/config/rules/cloud_services/socialmedia.json +82 -0
- package/config/rules/cloud_services/web_analytics.json +108 -0
- package/config/rules/components/active_content.json +157 -0
- package/config/rules/components/load_dll.json +66 -0
- package/config/rules/cryptography/algorithm_implementation.json +62 -0
- package/config/rules/cryptography/certificate.json +199 -0
- package/config/rules/cryptography/ciphers.json +174 -0
- package/config/rules/cryptography/crypto_currency.json +32 -0
- package/config/rules/cryptography/encoding.json +20 -0
- package/config/rules/cryptography/extended.json +220 -0
- package/config/rules/cryptography/external_libraries.json +141 -0
- package/config/rules/cryptography/hash_algorithm.json +98 -0
- package/config/rules/cryptography/key_derivation.json +65 -0
- package/config/rules/cryptography/protocol.json +156 -0
- package/config/rules/cryptography/random.json +97 -0
- package/config/rules/cryptography/weakssl.json +206 -0
- package/config/rules/data_handling/compressed_files.json +18 -0
- package/config/rules/data_handling/database.json +361 -0
- package/config/rules/data_handling/deserialization.json +296 -0
- package/config/rules/data_handling/json_parsing.json +49 -0
- package/config/rules/data_handling/media_parsing.json +33 -0
- package/config/rules/data_handling/pastebin.json +18 -0
- package/config/rules/data_handling/xml_parsing.json +168 -0
- package/config/rules/data_types/financial.json +106 -0
- package/config/rules/data_types/media.json +48 -0
- package/config/rules/data_types/secrets.json +91 -0
- package/config/rules/data_types/sensitive.json +176 -0
- package/config/rules/device_permissions/IOSPermissions.json +240 -0
- package/config/rules/device_permissions/UWP.json +221 -0
- package/config/rules/device_permissions/android_intents.json +599 -0
- package/config/rules/frameworks/PHP.json +172 -0
- package/config/rules/frameworks/build.json +189 -0
- package/config/rules/frameworks/c.json +45 -0
- package/config/rules/frameworks/csharp-nonMS.json +19 -0
- package/config/rules/frameworks/java.json +291 -0
- package/config/rules/frameworks/javascript.json +318 -0
- package/config/rules/frameworks/logging.json +103 -0
- package/config/rules/frameworks/microsoft.json +257 -0
- package/config/rules/frameworks/python.json +274 -0
- package/config/rules/frameworks/ruby.json +53 -0
- package/config/rules/frameworks/rust.json +77 -0
- package/config/rules/general/OSS_license.json +146 -0
- package/config/rules/general/code_metrics.json +132 -0
- package/config/rules/general/dependencies.json +199 -0
- package/config/rules/general/hygiene.json +47 -0
- package/config/rules/general/platforms.json +283 -0
- package/config/rules/general/solutioninfo.json +378 -0
- package/config/rules/infrastructure/hashicorp_packers_tmpl.json +18 -0
- package/config/rules/infrastructure/hashicorp_terraform_tmpl.json +19 -0
- package/config/rules/infrastructure/microsoft_arm_tmpl.json +198 -0
- package/config/rules/networkcomms/outbound_network.json +429 -0
- package/config/rules/os/acl.json +250 -0
- package/config/rules/os/dynamic_execution.json +359 -0
- package/config/rules/os/file_io.json +468 -0
- package/config/rules/os/process.json +179 -0
- package/config/rules/os/setenv.json +270 -0
- package/config/rules/os/system_registry.json +237 -0
- package/config/rules/os/user_accts.json +34 -0
- package/config/rules/security_feature/authentication.json +387 -0
- package/config/rules/security_feature/authorization.json +148 -0
- package/config/rules/test_frameworks/cpp_testing.json +194 -0
- package/config/rules/test_frameworks/go_testing.json +18 -0
- package/config/rules/test_frameworks/java_testing.json +720 -0
- package/config/rules/test_frameworks/javascript_testing.json +724 -0
- package/config/rules/test_frameworks/objectiveC_testing.json +146 -0
- package/config/rules/test_frameworks/php_testing.json +156 -0
- package/config/rules/test_frameworks/powershell_testing.json +17 -0
- package/config/rules/test_frameworks/python_testing.json +108 -0
- package/config/rules/test_frameworks/ruby_testing.json +114 -0
- package/config/rules/tools/pipeline.json +195 -0
- package/config/rules/webapp/comms.json +89 -0
- package/config/rules/webapp/headers.json +178 -0
- package/config/rules/webapp/media.json +56 -0
- package/config/rules/webapp/sessions.json +228 -0
- package/config/rules/webapp/storage.json +215 -0
- package/dist/config/.ignore +4 -0
- package/dist/config/comments.json +71 -0
- package/dist/config/fingerprints/_anomalies-full.json +116 -0
- package/dist/config/fingerprints/_extLibs.json +2555 -0
- package/dist/config/fingerprints/code_smells.json +94 -0
- package/dist/config/fingerprints/generated_code.json +17 -0
- package/dist/config/fingerprints/libraries.json +4667 -0
- package/dist/config/ignoredImports.txt +0 -0
- package/dist/config/insider-conf.properties +3 -0
- package/dist/config/rules/cloud_services/ad_networks.json +50 -0
- package/dist/config/rules/cloud_services/bigdata.json +21 -0
- package/dist/config/rules/cloud_services/cloud_hosting.json +398 -0
- package/dist/config/rules/cloud_services/data_storage.json +291 -0
- package/dist/config/rules/cloud_services/ecommerce.json +45 -0
- package/dist/config/rules/cloud_services/socialmedia.json +82 -0
- package/dist/config/rules/cloud_services/web_analytics.json +108 -0
- package/dist/config/rules/components/active_content.json +157 -0
- package/dist/config/rules/components/load_dll.json +66 -0
- package/dist/config/rules/cryptography/algorithm_implementation.json +62 -0
- package/dist/config/rules/cryptography/certificate.json +199 -0
- package/dist/config/rules/cryptography/ciphers.json +174 -0
- package/dist/config/rules/cryptography/crypto_currency.json +32 -0
- package/dist/config/rules/cryptography/encoding.json +20 -0
- package/dist/config/rules/cryptography/extended.json +220 -0
- package/dist/config/rules/cryptography/external_libraries.json +141 -0
- package/dist/config/rules/cryptography/hash_algorithm.json +98 -0
- package/dist/config/rules/cryptography/key_derivation.json +65 -0
- package/dist/config/rules/cryptography/protocol.json +156 -0
- package/dist/config/rules/cryptography/random.json +97 -0
- package/dist/config/rules/cryptography/weakssl.json +206 -0
- package/dist/config/rules/data_handling/compressed_files.json +18 -0
- package/dist/config/rules/data_handling/database.json +361 -0
- package/dist/config/rules/data_handling/deserialization.json +296 -0
- package/dist/config/rules/data_handling/json_parsing.json +49 -0
- package/dist/config/rules/data_handling/media_parsing.json +33 -0
- package/dist/config/rules/data_handling/pastebin.json +18 -0
- package/dist/config/rules/data_handling/xml_parsing.json +168 -0
- package/dist/config/rules/data_types/financial.json +106 -0
- package/dist/config/rules/data_types/media.json +48 -0
- package/dist/config/rules/data_types/secrets.json +91 -0
- package/dist/config/rules/data_types/sensitive.json +176 -0
- package/dist/config/rules/device_permissions/IOSPermissions.json +240 -0
- package/dist/config/rules/device_permissions/UWP.json +221 -0
- package/dist/config/rules/device_permissions/android_intents.json +599 -0
- package/dist/config/rules/frameworks/PHP.json +172 -0
- package/dist/config/rules/frameworks/build.json +189 -0
- package/dist/config/rules/frameworks/c.json +45 -0
- package/dist/config/rules/frameworks/csharp-nonMS.json +19 -0
- package/dist/config/rules/frameworks/java.json +291 -0
- package/dist/config/rules/frameworks/javascript.json +318 -0
- package/dist/config/rules/frameworks/logging.json +103 -0
- package/dist/config/rules/frameworks/microsoft.json +257 -0
- package/dist/config/rules/frameworks/python.json +274 -0
- package/dist/config/rules/frameworks/ruby.json +53 -0
- package/dist/config/rules/frameworks/rust.json +77 -0
- package/dist/config/rules/general/OSS_license.json +146 -0
- package/dist/config/rules/general/code_metrics.json +132 -0
- package/dist/config/rules/general/dependencies.json +199 -0
- package/dist/config/rules/general/hygiene.json +47 -0
- package/dist/config/rules/general/platforms.json +283 -0
- package/dist/config/rules/general/solutioninfo.json +378 -0
- package/dist/config/rules/infrastructure/hashicorp_packers_tmpl.json +18 -0
- package/dist/config/rules/infrastructure/hashicorp_terraform_tmpl.json +19 -0
- package/dist/config/rules/infrastructure/microsoft_arm_tmpl.json +198 -0
- package/dist/config/rules/networkcomms/outbound_network.json +429 -0
- package/dist/config/rules/os/acl.json +250 -0
- package/dist/config/rules/os/dynamic_execution.json +359 -0
- package/dist/config/rules/os/file_io.json +468 -0
- package/dist/config/rules/os/process.json +179 -0
- package/dist/config/rules/os/setenv.json +270 -0
- package/dist/config/rules/os/system_registry.json +237 -0
- package/dist/config/rules/os/user_accts.json +34 -0
- package/dist/config/rules/security_feature/authentication.json +387 -0
- package/dist/config/rules/security_feature/authorization.json +148 -0
- package/dist/config/rules/test_frameworks/cpp_testing.json +194 -0
- package/dist/config/rules/test_frameworks/go_testing.json +18 -0
- package/dist/config/rules/test_frameworks/java_testing.json +720 -0
- package/dist/config/rules/test_frameworks/javascript_testing.json +724 -0
- package/dist/config/rules/test_frameworks/objectiveC_testing.json +146 -0
- package/dist/config/rules/test_frameworks/php_testing.json +156 -0
- package/dist/config/rules/test_frameworks/powershell_testing.json +17 -0
- package/dist/config/rules/test_frameworks/python_testing.json +108 -0
- package/dist/config/rules/test_frameworks/ruby_testing.json +114 -0
- package/dist/config/rules/tools/pipeline.json +195 -0
- package/dist/config/rules/webapp/comms.json +89 -0
- package/dist/config/rules/webapp/headers.json +178 -0
- package/dist/config/rules/webapp/media.json +56 -0
- package/dist/config/rules/webapp/sessions.json +228 -0
- package/dist/config/rules/webapp/storage.json +215 -0
- package/dist/index.js +13 -0
- package/dist/insider.jar +0 -0
- package/dist/insider.js +7 -0
- package/dist/lib.js +21 -0
- package/docs/config/config.md +3 -0
- package/docs/config/ignore.md +3 -0
- package/docs/config/languages.md +3 -0
- package/docs/index.md +58 -0
- package/dxworks-site.json +13 -0
- package/gradle.properties +0 -0
- package/gradlew +240 -0
- package/gradlew.bat +91 -0
- package/insider/README.md +89 -0
- package/insider/config/.ignore +4 -0
- package/insider/config/comments.json +71 -0
- package/insider/config/fingerprints/_anomalies-full.json +116 -0
- package/insider/config/fingerprints/_extLibs.json +2555 -0
- package/insider/config/fingerprints/code_smells.json +94 -0
- package/insider/config/fingerprints/generated_code.json +17 -0
- package/insider/config/fingerprints/libraries.json +4667 -0
- package/insider/config/ignoredImports.txt +0 -0
- package/insider/config/insider-conf.properties +3 -0
- package/insider/config/rules/cloud_services/ad_networks.json +50 -0
- package/insider/config/rules/cloud_services/bigdata.json +21 -0
- package/insider/config/rules/cloud_services/cloud_hosting.json +398 -0
- package/insider/config/rules/cloud_services/data_storage.json +291 -0
- package/insider/config/rules/cloud_services/ecommerce.json +45 -0
- package/insider/config/rules/cloud_services/socialmedia.json +82 -0
- package/insider/config/rules/cloud_services/web_analytics.json +108 -0
- package/insider/config/rules/components/active_content.json +157 -0
- package/insider/config/rules/components/load_dll.json +66 -0
- package/insider/config/rules/cryptography/algorithm_implementation.json +62 -0
- package/insider/config/rules/cryptography/certificate.json +199 -0
- package/insider/config/rules/cryptography/ciphers.json +174 -0
- package/insider/config/rules/cryptography/crypto_currency.json +32 -0
- package/insider/config/rules/cryptography/encoding.json +20 -0
- package/insider/config/rules/cryptography/extended.json +220 -0
- package/insider/config/rules/cryptography/external_libraries.json +141 -0
- package/insider/config/rules/cryptography/hash_algorithm.json +98 -0
- package/insider/config/rules/cryptography/key_derivation.json +65 -0
- package/insider/config/rules/cryptography/protocol.json +156 -0
- package/insider/config/rules/cryptography/random.json +97 -0
- package/insider/config/rules/cryptography/weakssl.json +206 -0
- package/insider/config/rules/data_handling/compressed_files.json +18 -0
- package/insider/config/rules/data_handling/database.json +361 -0
- package/insider/config/rules/data_handling/deserialization.json +296 -0
- package/insider/config/rules/data_handling/json_parsing.json +49 -0
- package/insider/config/rules/data_handling/media_parsing.json +33 -0
- package/insider/config/rules/data_handling/pastebin.json +18 -0
- package/insider/config/rules/data_handling/xml_parsing.json +168 -0
- package/insider/config/rules/data_types/financial.json +106 -0
- package/insider/config/rules/data_types/media.json +48 -0
- package/insider/config/rules/data_types/secrets.json +91 -0
- package/insider/config/rules/data_types/sensitive.json +176 -0
- package/insider/config/rules/device_permissions/IOSPermissions.json +240 -0
- package/insider/config/rules/device_permissions/UWP.json +221 -0
- package/insider/config/rules/device_permissions/android_intents.json +599 -0
- package/insider/config/rules/frameworks/PHP.json +172 -0
- package/insider/config/rules/frameworks/build.json +189 -0
- package/insider/config/rules/frameworks/c.json +45 -0
- package/insider/config/rules/frameworks/csharp-nonMS.json +19 -0
- package/insider/config/rules/frameworks/java.json +291 -0
- package/insider/config/rules/frameworks/javascript.json +318 -0
- package/insider/config/rules/frameworks/logging.json +103 -0
- package/insider/config/rules/frameworks/microsoft.json +257 -0
- package/insider/config/rules/frameworks/python.json +274 -0
- package/insider/config/rules/frameworks/ruby.json +53 -0
- package/insider/config/rules/frameworks/rust.json +77 -0
- package/insider/config/rules/general/OSS_license.json +146 -0
- package/insider/config/rules/general/code_metrics.json +132 -0
- package/insider/config/rules/general/dependencies.json +199 -0
- package/insider/config/rules/general/hygiene.json +47 -0
- package/insider/config/rules/general/platforms.json +283 -0
- package/insider/config/rules/general/solutioninfo.json +378 -0
- package/insider/config/rules/infrastructure/hashicorp_packers_tmpl.json +18 -0
- package/insider/config/rules/infrastructure/hashicorp_terraform_tmpl.json +19 -0
- package/insider/config/rules/infrastructure/microsoft_arm_tmpl.json +198 -0
- package/insider/config/rules/networkcomms/outbound_network.json +429 -0
- package/insider/config/rules/os/acl.json +250 -0
- package/insider/config/rules/os/dynamic_execution.json +359 -0
- package/insider/config/rules/os/file_io.json +468 -0
- package/insider/config/rules/os/process.json +179 -0
- package/insider/config/rules/os/setenv.json +270 -0
- package/insider/config/rules/os/system_registry.json +237 -0
- package/insider/config/rules/os/user_accts.json +34 -0
- package/insider/config/rules/security_feature/authentication.json +387 -0
- package/insider/config/rules/security_feature/authorization.json +148 -0
- package/insider/config/rules/test_frameworks/cpp_testing.json +194 -0
- package/insider/config/rules/test_frameworks/go_testing.json +18 -0
- package/insider/config/rules/test_frameworks/java_testing.json +720 -0
- package/insider/config/rules/test_frameworks/javascript_testing.json +724 -0
- package/insider/config/rules/test_frameworks/objectiveC_testing.json +146 -0
- package/insider/config/rules/test_frameworks/php_testing.json +156 -0
- package/insider/config/rules/test_frameworks/powershell_testing.json +17 -0
- package/insider/config/rules/test_frameworks/python_testing.json +108 -0
- package/insider/config/rules/test_frameworks/ruby_testing.json +114 -0
- package/insider/config/rules/tools/pipeline.json +195 -0
- package/insider/config/rules/webapp/comms.json +89 -0
- package/insider/config/rules/webapp/headers.json +178 -0
- package/insider/config/rules/webapp/media.json +56 -0
- package/insider/config/rules/webapp/sessions.json +228 -0
- package/insider/config/rules/webapp/storage.json +215 -0
- package/insider/insider.bat +1 -0
- package/insider/insider.jar +0 -0
- package/insider/insider.sh +1 -0
- package/insider/languages.yml +3988 -0
- package/instrument.yml +37 -0
- package/languages.yml +3988 -0
- package/lib/index.js +13 -0
- package/lib/insider.js +7 -0
- package/lib/lib.js +21 -0
- package/lombok.config +2 -0
- package/mkdocs.yml +18 -0
- package/package.json +51 -0
- package/releaseNotes/v2.6.0.md +1 -0
- package/releaseNotes/v2.7.1.md +1 -0
- package/settings.gradle +2 -0
- package/src/main/java/org/dxworks/insider/ChronosTag.java +14 -0
- package/src/main/java/org/dxworks/insider/Insider.java +214 -0
- package/src/main/java/org/dxworks/insider/InsiderAnalysis.java +7 -0
- package/src/main/java/org/dxworks/insider/InsiderFile.java +125 -0
- package/src/main/java/org/dxworks/insider/InsiderOptions.java +78 -0
- package/src/main/java/org/dxworks/insider/InsiderResult.java +15 -0
- package/src/main/java/org/dxworks/insider/application/inspector/CodeRuleExtractor.java +14 -0
- package/src/main/java/org/dxworks/insider/application/inspector/CommentRuleExtractor.java +14 -0
- package/src/main/java/org/dxworks/insider/application/inspector/FileRuleExtractor.java +14 -0
- package/src/main/java/org/dxworks/insider/application/inspector/RuleExtractor.java +11 -0
- package/src/main/java/org/dxworks/insider/application/inspector/dtos/Comment.java +18 -0
- package/src/main/java/org/dxworks/insider/application/inspector/dtos/CommentPattern.java +44 -0
- package/src/main/java/org/dxworks/insider/application/inspector/dtos/Condition.java +15 -0
- package/src/main/java/org/dxworks/insider/application/inspector/dtos/InsiderPattern.java +149 -0
- package/src/main/java/org/dxworks/insider/application/inspector/dtos/PatternMatch.java +23 -0
- package/src/main/java/org/dxworks/insider/application/inspector/dtos/Rule.java +61 -0
- package/src/main/java/org/dxworks/insider/application/inspector/services/CommentService.java +165 -0
- package/src/main/java/org/dxworks/insider/application/inspector/services/RuleService.java +54 -0
- package/src/main/java/org/dxworks/insider/commands/AddCommand.java +125 -0
- package/src/main/java/org/dxworks/insider/commands/AllFilesCommand.java +4 -0
- package/src/main/java/org/dxworks/insider/commands/ConvertCommand.java +55 -0
- package/src/main/java/org/dxworks/insider/commands/DetectCommand.java +42 -0
- package/src/main/java/org/dxworks/insider/commands/DiagnoseCommand.java +74 -0
- package/src/main/java/org/dxworks/insider/commands/ExtractCommand.java +35 -0
- package/src/main/java/org/dxworks/insider/commands/FindCommand.java +102 -0
- package/src/main/java/org/dxworks/insider/commands/HelpCommand.java +56 -0
- package/src/main/java/org/dxworks/insider/commands/IndentationCount.java +69 -0
- package/src/main/java/org/dxworks/insider/commands/InsiderCommand.java +71 -0
- package/src/main/java/org/dxworks/insider/commands/InspectCommand.java +98 -0
- package/src/main/java/org/dxworks/insider/commands/MeasureCommand.java +47 -0
- package/src/main/java/org/dxworks/insider/commands/NoFilesCommand.java +4 -0
- package/src/main/java/org/dxworks/insider/commands/VersionCommand.java +34 -0
- package/src/main/java/org/dxworks/insider/configuration/InsiderConfiguration.java +123 -0
- package/src/main/java/org/dxworks/insider/constants/InsiderConstants.java +19 -0
- package/src/main/java/org/dxworks/insider/depext/AbstractImportsProcessor.java +57 -0
- package/src/main/java/org/dxworks/insider/depext/CPPImportsProcessor.java +55 -0
- package/src/main/java/org/dxworks/insider/depext/CSharpImportsProcessor.java +53 -0
- package/src/main/java/org/dxworks/insider/depext/DependencyExtractor.java +105 -0
- package/src/main/java/org/dxworks/insider/depext/ImportItem.java +19 -0
- package/src/main/java/org/dxworks/insider/depext/ImportResult.java +32 -0
- package/src/main/java/org/dxworks/insider/depext/JavastackImportsProcessor.java +88 -0
- package/src/main/java/org/dxworks/insider/depext/VBImportsProcessor.java +41 -0
- package/src/main/java/org/dxworks/insider/exceptions/InsiderException.java +7 -0
- package/src/main/java/org/dxworks/insider/library/detector/C_ImportsContainer.java +73 -0
- package/src/main/java/org/dxworks/insider/library/detector/ImportsContainer.java +122 -0
- package/src/main/java/org/dxworks/insider/library/detector/JavaImportsContainer.java +63 -0
- package/src/main/java/org/dxworks/insider/library/detector/LibraryDetector.java +150 -0
- package/src/main/java/org/dxworks/insider/library/detector/LibraryDetectorLanguage.java +6 -0
- package/src/main/java/org/dxworks/insider/library/detector/model/PackagingUnit.java +26 -0
- package/src/main/java/org/dxworks/insider/technology/finder/LinguistService.java +79 -0
- package/src/main/java/org/dxworks/insider/technology/finder/converters/XmlToJsonConverter.java +41 -0
- package/src/main/java/org/dxworks/insider/technology/finder/exceptions/FingerprintParseException.java +7 -0
- package/src/main/java/org/dxworks/insider/technology/finder/model/Technology.java +73 -0
- package/src/main/java/org/dxworks/insider/technology/finder/model/json/JsonConfigurationDTO.java +14 -0
- package/src/main/java/org/dxworks/insider/technology/finder/model/json/TechnologyJsonDTO.java +66 -0
- package/src/main/java/org/dxworks/insider/technology/finder/model/xml/old/CategoryXmlDTO.java +21 -0
- package/src/main/java/org/dxworks/insider/technology/finder/model/xml/old/ConfigurationDataXmlDTO.java +17 -0
- package/src/main/java/org/dxworks/insider/technology/finder/model/xml/old/FingerprintXmlDTO.java +17 -0
- package/src/main/java/org/dxworks/insider/technology/finder/model/xml/old/LanguageXmlDTO.java +20 -0
- package/src/main/java/org/dxworks/insider/technology/finder/model/xml/old/LanguagesXmlDTO.java +18 -0
- package/src/main/java/org/dxworks/insider/technology/finder/model/xml/old/TechnologyXmlDTO.java +19 -0
- package/src/main/java/org/dxworks/insider/technology/finder/model/xml/old/XmlConfigurationDTO.java +17 -0
- package/src/main/java/org/dxworks/insider/technology/finder/parsers/FingerprintsParser.java +14 -0
- package/src/main/java/org/dxworks/insider/technology/finder/parsers/FingerprintsXmlParser.java +57 -0
- package/src/main/java/org/dxworks/insider/technology/finder/parsers/JavaLibrariesCsvParser.java +71 -0
- package/src/main/java/org/dxworks/insider/technology/finder/parsers/JsonFingerprintParser.java +58 -0
- package/src/main/java/org/dxworks/insider/utils/FileUtils.java +45 -0
- package/src/main/java/org/dxworks/insider/utils/ImportUtils.java +21 -0
- package/src/main/java/org/dxworks/insider/utils/LibraryImport.java +17 -0
- package/src/main/java/org/dxworks/insider/utils/LibraryImportInOtherTechnology.java +30 -0
- package/src/main/java/org/dxworks/insider/utils/MapUtils.java +19 -0
- package/src/main/resources/insider-version +1 -0
- package/src/test/java/org/dxworks/insider/application/inspector/services/CommentServiceTest.java +40 -0
- package/src/test/java/org/dxworks/insider/technology/finder/parsers/FingerprintsXmlParserTest.java +15 -0
- package/src/test/java/org/dxworks/insider/utils/FileUtilsTest.java +31 -0
- package/src/test/java/org/dxworks/insider/utils/ImportUtilsTest.java +24 -0
- package/src/test/java/org/dxworks/insider/utils/transformers/JsonToCsvTransformerTest.java +18 -0
- package/src/test/resources/Test1.java +21 -0
- package/src/test/resources/Test2.java +21 -0
- package/src/test/resources/cobol/CM201M.CBL +88 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package org.dxworks.insider.commands;
|
|
2
|
+
|
|
3
|
+
import lombok.extern.slf4j.Slf4j;
|
|
4
|
+
import org.dxworks.insider.InsiderFile;
|
|
5
|
+
import org.dxworks.insider.configuration.InsiderConfiguration;
|
|
6
|
+
|
|
7
|
+
import java.util.List;
|
|
8
|
+
|
|
9
|
+
@Slf4j
|
|
10
|
+
public class VersionCommand implements NoFilesCommand {
|
|
11
|
+
@Override
|
|
12
|
+
public boolean parse(List<String> args) {
|
|
13
|
+
if (args.size() != 1)
|
|
14
|
+
return false;
|
|
15
|
+
|
|
16
|
+
return VERSION.contains(args.get(0));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
public void execute(List<InsiderFile> insiderFiles, List<String> args) {
|
|
21
|
+
|
|
22
|
+
System.out.println("Insider " + InsiderConfiguration.getInstance().getInsiderVersion());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
public String usage() {
|
|
27
|
+
return "insider {-v | -version | --version | version}";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public String getName() {
|
|
32
|
+
return "version";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
package org.dxworks.insider.configuration;
|
|
2
|
+
|
|
3
|
+
import lombok.extern.slf4j.Slf4j;
|
|
4
|
+
import org.dxworks.argumenthor.Argumenthor;
|
|
5
|
+
import org.dxworks.argumenthor.config.ArgumenthorConfiguration;
|
|
6
|
+
import org.dxworks.argumenthor.config.fields.impl.NumberField;
|
|
7
|
+
import org.dxworks.argumenthor.config.fields.impl.StringField;
|
|
8
|
+
import org.dxworks.argumenthor.config.fields.impl.StringListField;
|
|
9
|
+
import org.dxworks.argumenthor.config.sources.impl.EnvSource;
|
|
10
|
+
import org.dxworks.argumenthor.config.sources.impl.PropertiesSource;
|
|
11
|
+
import org.dxworks.insider.technology.finder.LinguistService;
|
|
12
|
+
|
|
13
|
+
import java.io.IOException;
|
|
14
|
+
import java.util.List;
|
|
15
|
+
import java.util.stream.Collectors;
|
|
16
|
+
|
|
17
|
+
import static org.dxworks.insider.constants.InsiderConstants.*;
|
|
18
|
+
|
|
19
|
+
@Slf4j
|
|
20
|
+
public class InsiderConfiguration {
|
|
21
|
+
|
|
22
|
+
private static InsiderConfiguration _instance = new InsiderConfiguration();
|
|
23
|
+
private static Argumenthor argumenthor;
|
|
24
|
+
|
|
25
|
+
private String insiderVersion = null;
|
|
26
|
+
private String projectID = null;
|
|
27
|
+
private String rootFolder = null;
|
|
28
|
+
private List<String> languages = null;
|
|
29
|
+
private String languagesFile = null;
|
|
30
|
+
private int depextMaxNamespaceLength = -1;
|
|
31
|
+
|
|
32
|
+
private InsiderConfiguration() {
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public static InsiderConfiguration getInstance() {
|
|
36
|
+
return _instance;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public void load() {
|
|
40
|
+
|
|
41
|
+
System.out.println("Reading configuration");
|
|
42
|
+
readInsiderVersion();
|
|
43
|
+
|
|
44
|
+
ArgumenthorConfiguration argumenthorConfiguration = new ArgumenthorConfiguration(
|
|
45
|
+
new StringField(PROJECT_ID, null),
|
|
46
|
+
new StringField(ROOT_FOLDER, "."),
|
|
47
|
+
new StringListField(LANGUAGES, List.of(), ","),
|
|
48
|
+
new StringField(LINGUIST_FILE, DEFAULT_LINGUIST_FILE),
|
|
49
|
+
new NumberField(DEPEXT_MAX_NAMESPACE_LENGTH, DEFAULT_DEPEXT_MAX_NAMESPACE_LENGTH)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
PropertiesSource propertiesSource = new PropertiesSource();
|
|
53
|
+
propertiesSource.setPath("config/insider-conf.properties");
|
|
54
|
+
argumenthorConfiguration.addSource(new EnvSource("INSIDER"));
|
|
55
|
+
argumenthorConfiguration.addSource(propertiesSource);
|
|
56
|
+
argumenthor = new Argumenthor(argumenthorConfiguration);
|
|
57
|
+
|
|
58
|
+
LinguistService.getInstance().initLinguist(getLanguagesFile());
|
|
59
|
+
|
|
60
|
+
System.out.println("Insider " + getInsiderVersion());
|
|
61
|
+
System.out.println("Project ID: " + getProjectID());
|
|
62
|
+
System.out.println("Root Folder: " + getRootFolder());
|
|
63
|
+
System.out.println("Languages: " + getLanguages());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public void readInsiderVersion() {
|
|
67
|
+
try {
|
|
68
|
+
insiderVersion = new String(getClass().getClassLoader().getResourceAsStream("insider-version").readAllBytes()).trim();
|
|
69
|
+
} catch (IOException e) {
|
|
70
|
+
log.warn("Could not read Insider Version", e);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public String getRootFolder() {
|
|
75
|
+
if (rootFolder == null) {
|
|
76
|
+
rootFolder = (String) argumenthor.getRawValue(ROOT_FOLDER);
|
|
77
|
+
if (rootFolder.endsWith("\\") || rootFolder.endsWith("/")) {
|
|
78
|
+
rootFolder = rootFolder.substring(0, rootFolder.length() - 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return rootFolder;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public String getProjectID() {
|
|
86
|
+
if (projectID == null) {
|
|
87
|
+
projectID = (String) argumenthor.getRawValue(PROJECT_ID);
|
|
88
|
+
}
|
|
89
|
+
return projectID;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public List<String> getLanguages() {
|
|
93
|
+
if (languages == null) {
|
|
94
|
+
languages = ((List<String>) argumenthor.getRawValue(LANGUAGES)).stream()
|
|
95
|
+
.filter(s -> !s.isBlank()).collect(Collectors.toList());
|
|
96
|
+
}
|
|
97
|
+
return languages;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public String getLanguagesFile() {
|
|
101
|
+
if (languagesFile == null) {
|
|
102
|
+
languagesFile = (String) argumenthor.getRawValue(LINGUIST_FILE);
|
|
103
|
+
}
|
|
104
|
+
return languagesFile;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public int getDepextMaxNamespaceLength() {
|
|
108
|
+
if (depextMaxNamespaceLength == -1) {
|
|
109
|
+
try {
|
|
110
|
+
depextMaxNamespaceLength = (int) argumenthor.getRawValue(DEPEXT_MAX_NAMESPACE_LENGTH);
|
|
111
|
+
}
|
|
112
|
+
catch (Exception e) {
|
|
113
|
+
depextMaxNamespaceLength = DEFAULT_DEPEXT_MAX_NAMESPACE_LENGTH;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return depextMaxNamespaceLength;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public String getInsiderVersion() {
|
|
121
|
+
return insiderVersion;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package org.dxworks.insider.constants;
|
|
2
|
+
|
|
3
|
+
public interface InsiderConstants {
|
|
4
|
+
|
|
5
|
+
String PROJECT_ID = "projectID";
|
|
6
|
+
String ROOT_FOLDER = "rootFolder";
|
|
7
|
+
String LANGUAGES = "languages";
|
|
8
|
+
String DEPEXT_MAX_NAMESPACE_LENGTH = "depext.max.namespace.length";
|
|
9
|
+
String LINGUIST_FILE = "linguist.file";
|
|
10
|
+
String DEFAULT_LINGUIST_FILE = "languages.yml";
|
|
11
|
+
int DEFAULT_DEPEXT_MAX_NAMESPACE_LENGTH = 200;
|
|
12
|
+
|
|
13
|
+
String CONFIGURATION_FOLDER = "config";
|
|
14
|
+
String RESULTS_FOLDER = "results";
|
|
15
|
+
|
|
16
|
+
String CONFIGURATION_FILE = "insider-conf.properties";
|
|
17
|
+
String VERSION_FILE = ".insider-version";
|
|
18
|
+
String STARS = "*******************************************************************************";
|
|
19
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package org.dxworks.insider.depext;
|
|
2
|
+
|
|
3
|
+
import org.dxworks.insider.InsiderFile;
|
|
4
|
+
import org.dxworks.insider.utils.FileUtils;
|
|
5
|
+
|
|
6
|
+
import java.util.ArrayList;
|
|
7
|
+
import java.util.Arrays;
|
|
8
|
+
import java.util.List;
|
|
9
|
+
|
|
10
|
+
public abstract class AbstractImportsProcessor {
|
|
11
|
+
protected List<String> lines;
|
|
12
|
+
private final InsiderFile file;
|
|
13
|
+
protected String namespace;
|
|
14
|
+
private final List<ImportItem> importedItems = new ArrayList<>();
|
|
15
|
+
|
|
16
|
+
public AbstractImportsProcessor(InsiderFile file) {
|
|
17
|
+
|
|
18
|
+
lines = Arrays.asList(FileUtils.removeComments(file.getContent()).split("\n"));
|
|
19
|
+
this.file = file;
|
|
20
|
+
|
|
21
|
+
lines.stream()
|
|
22
|
+
.map(String::trim)
|
|
23
|
+
.map(it -> it.replaceAll("[^\\x00-\\x7F]", ""))
|
|
24
|
+
.forEach(trimmedLine -> {
|
|
25
|
+
if (namespace == null) {
|
|
26
|
+
String foundNamespace = namespaceLine(trimmedLine);
|
|
27
|
+
if (foundNamespace != null) namespace = foundNamespace;
|
|
28
|
+
}
|
|
29
|
+
List<ImportItem> crtImportItems = importLine(trimmedLine);
|
|
30
|
+
if (crtImportItems != null) importedItems.addAll(crtImportItems);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public ImportResult extract() {
|
|
36
|
+
ImportResult resultObject = new ImportResult();
|
|
37
|
+
|
|
38
|
+
resultObject.filename = file.getFullyQualifiedName();
|
|
39
|
+
resultObject.language = language();
|
|
40
|
+
resultObject.namespace = namespace();
|
|
41
|
+
resultObject.importedItems = importedItems;
|
|
42
|
+
resultObject.linesOfCode = (lines != null) ? lines.size() : 0;
|
|
43
|
+
|
|
44
|
+
return resultObject;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private String namespace() {
|
|
48
|
+
return namespace == null ? "" : namespace;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected abstract String language();
|
|
52
|
+
|
|
53
|
+
protected abstract String namespaceLine(String trimmedLine);
|
|
54
|
+
|
|
55
|
+
protected abstract List<ImportItem> importLine(String trimmedLine);
|
|
56
|
+
|
|
57
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
package org.dxworks.insider.depext;
|
|
2
|
+
|
|
3
|
+
import org.dxworks.insider.InsiderFile;
|
|
4
|
+
|
|
5
|
+
import java.util.Collections;
|
|
6
|
+
import java.util.List;
|
|
7
|
+
import java.util.regex.Matcher;
|
|
8
|
+
import java.util.regex.Pattern;
|
|
9
|
+
|
|
10
|
+
public class CPPImportsProcessor extends AbstractImportsProcessor {
|
|
11
|
+
public static int counter = 0;
|
|
12
|
+
|
|
13
|
+
public CPPImportsProcessor(InsiderFile insiderFile) {
|
|
14
|
+
super(insiderFile);
|
|
15
|
+
counter++;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
protected String language() {
|
|
20
|
+
return "cpp";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Override
|
|
24
|
+
protected String namespaceLine(String trimmedLine) {
|
|
25
|
+
if (trimmedLine.startsWith("namespace")) {
|
|
26
|
+
String patternString = "(namespace\\s+)(\\w+)(.*)";
|
|
27
|
+
|
|
28
|
+
Matcher matcher = Pattern.compile(patternString).matcher(trimmedLine);
|
|
29
|
+
if (matcher.find()) return matcher.group(2);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@Override
|
|
37
|
+
protected List<ImportItem> importLine(String trimmedLine) {
|
|
38
|
+
if (trimmedLine.startsWith("#include ") == false) return null;
|
|
39
|
+
|
|
40
|
+
String patternString = "(#include\\s+<)([\\w\\d/.\\\\]+)(>.*)";
|
|
41
|
+
|
|
42
|
+
Matcher matcher = Pattern.compile(patternString).matcher(trimmedLine);
|
|
43
|
+
if (matcher.find())
|
|
44
|
+
return Collections.singletonList(new ImportItem(matcher.group(2), "library"));
|
|
45
|
+
|
|
46
|
+
patternString = "(#include\\s+\")([\\w/.]+)(\")";
|
|
47
|
+
|
|
48
|
+
matcher = Pattern.compile(patternString).matcher(trimmedLine);
|
|
49
|
+
if (matcher.find())
|
|
50
|
+
return Collections.singletonList(new ImportItem(matcher.group(2)));
|
|
51
|
+
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
package org.dxworks.insider.depext;
|
|
2
|
+
|
|
3
|
+
import org.dxworks.insider.InsiderFile;
|
|
4
|
+
|
|
5
|
+
import java.util.Collections;
|
|
6
|
+
import java.util.List;
|
|
7
|
+
import java.util.regex.Matcher;
|
|
8
|
+
import java.util.regex.Pattern;
|
|
9
|
+
|
|
10
|
+
public class CSharpImportsProcessor extends AbstractImportsProcessor {
|
|
11
|
+
public static int counter = 0;
|
|
12
|
+
|
|
13
|
+
public CSharpImportsProcessor(InsiderFile insiderFile) {
|
|
14
|
+
super(insiderFile);
|
|
15
|
+
counter++;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
protected String language() {
|
|
20
|
+
return "csharp";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Override
|
|
24
|
+
protected String namespaceLine(String trimmedLine) {
|
|
25
|
+
return trimmedLine.startsWith("namespace") && trimmedLine.length() >= 10 ?
|
|
26
|
+
trimmedLine.substring(10).trim().replaceAll(";", "") : null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
protected List<ImportItem> importLine(String trimmedLine) {
|
|
32
|
+
if (trimmedLine.startsWith("using") == false) return null;
|
|
33
|
+
if (trimmedLine.contains("(")) return null;
|
|
34
|
+
|
|
35
|
+
Pattern p = Pattern.compile("(using|using static)\\s+([\\w.]+\\s*)=*\\s*([\\w.<>\\s,]*);");
|
|
36
|
+
Matcher m = p.matcher(trimmedLine.trim());
|
|
37
|
+
if (m.find() == false) return null;
|
|
38
|
+
|
|
39
|
+
String attribute = "";
|
|
40
|
+
String importedNamespace = "";
|
|
41
|
+
|
|
42
|
+
if (trimmedLine.startsWith("using static")) {
|
|
43
|
+
attribute = "static";
|
|
44
|
+
importedNamespace = m.group(3);
|
|
45
|
+
} else {
|
|
46
|
+
importedNamespace = trimmedLine.contains("=") ? m.group(3) : m.group(2);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
importedNamespace = importedNamespace.replace(",", "");
|
|
50
|
+
|
|
51
|
+
return Collections.singletonList(new ImportItem(importedNamespace, attribute));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
package org.dxworks.insider.depext;
|
|
2
|
+
|
|
3
|
+
import org.dxworks.insider.InsiderFile;
|
|
4
|
+
import org.dxworks.insider.configuration.InsiderConfiguration;
|
|
5
|
+
|
|
6
|
+
import java.io.File;
|
|
7
|
+
import java.io.FileNotFoundException;
|
|
8
|
+
import java.io.PrintWriter;
|
|
9
|
+
import java.nio.file.Path;
|
|
10
|
+
import java.util.ArrayList;
|
|
11
|
+
import java.util.Arrays;
|
|
12
|
+
import java.util.List;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
public class DependencyExtractor {
|
|
16
|
+
private static final List<String> cppExtensions = Arrays.asList(".c", ".cpp", ".hpp", ".cc", ".h", ".hh", ".cxx", ".hxx");
|
|
17
|
+
private static final String javaExtension = "java";
|
|
18
|
+
private static final String visualBasicExtension = ".vb";
|
|
19
|
+
private static final String kotlinExtension = "kt";
|
|
20
|
+
private static final String scalaExtension = "scala";
|
|
21
|
+
private static final String csExtension = "cs";
|
|
22
|
+
private static final String groovyExtension = "groovy";
|
|
23
|
+
private final List<ImportResult> resultsList = new ArrayList<>();
|
|
24
|
+
private int counterFiles = 0;
|
|
25
|
+
private int countIgnoredFiles = 0;
|
|
26
|
+
|
|
27
|
+
public void processAndWriteResults(List<InsiderFile> files) {
|
|
28
|
+
files.forEach(this::execute);
|
|
29
|
+
System.out.println("\n\nTotal files in folder: " + counterFiles);
|
|
30
|
+
System.out.println("Files skipped: " + countIgnoredFiles + "\n");
|
|
31
|
+
|
|
32
|
+
if (JavastackImportsProcessor.hasFiles()) System.out.println(JavastackImportsProcessor.statistics());
|
|
33
|
+
if (CSharpImportsProcessor.counter > 0)
|
|
34
|
+
System.out.println(CSharpImportsProcessor.counter + " C# files processed");
|
|
35
|
+
if (CPPImportsProcessor.counter > 0) System.out.println(CPPImportsProcessor.counter + " C++ files processed");
|
|
36
|
+
if (VBImportsProcessor.counter > 0) System.out.println(VBImportsProcessor.counter + " VB.NET files processed");
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
String outputFilename = "results/" + InsiderConfiguration.getInstance().getProjectID() + "-depext.csv";
|
|
40
|
+
try {
|
|
41
|
+
Path.of("results").toFile().mkdirs();
|
|
42
|
+
PrintWriter outputFile = new PrintWriter(outputFilename);
|
|
43
|
+
|
|
44
|
+
System.err.println("Writing " + resultsList.size() + " entries to output file: " + outputFilename);
|
|
45
|
+
|
|
46
|
+
outputFile.println(ImportResult.header());
|
|
47
|
+
resultsList.stream()
|
|
48
|
+
.filter(it -> it.namespace.length() < InsiderConfiguration.getInstance().getDepextMaxNamespaceLength())
|
|
49
|
+
.forEach(outputFile::println);
|
|
50
|
+
outputFile.close();
|
|
51
|
+
} catch (FileNotFoundException e) {
|
|
52
|
+
System.err.println("\nCannot write to file: " + outputFilename);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private void execute(InsiderFile insiderFile) {
|
|
57
|
+
AbstractImportsProcessor processor = createProcessor(insiderFile);
|
|
58
|
+
|
|
59
|
+
counterFiles++;
|
|
60
|
+
if (counterFiles % 1000 == 0) System.out.print("*");
|
|
61
|
+
|
|
62
|
+
if (processor != null) resultsList.add(processor.extract());
|
|
63
|
+
else countIgnoredFiles++;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private AbstractImportsProcessor createProcessor(InsiderFile insiderFile) {
|
|
67
|
+
String extension = extension(insiderFile.getPath());
|
|
68
|
+
|
|
69
|
+
if (extension == null) return null;
|
|
70
|
+
|
|
71
|
+
if (extension.endsWith(javaExtension)) return new JavastackImportsProcessor(insiderFile, "java");
|
|
72
|
+
else if (extension.endsWith(kotlinExtension)) return new JavastackImportsProcessor(insiderFile, "kotlin");
|
|
73
|
+
else if (extension.endsWith(scalaExtension)) return new JavastackImportsProcessor(insiderFile, "scala");
|
|
74
|
+
else if (extension.endsWith(groovyExtension)) return new JavastackImportsProcessor(insiderFile, "groovy");
|
|
75
|
+
else if (extension.endsWith(csExtension) && isRelevantCSharpFolder(insiderFile.getPath()))
|
|
76
|
+
return new CSharpImportsProcessor(insiderFile);
|
|
77
|
+
else if (cppExtensions.contains(extension)) return new CPPImportsProcessor(insiderFile);
|
|
78
|
+
else if (extension.endsWith(visualBasicExtension)) return new VBImportsProcessor(insiderFile);
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private boolean isRelevantCSharpFolder(String path) {
|
|
85
|
+
if (path.contains(File.separator + ".vs" + File.separator)) return false;
|
|
86
|
+
if (path.contains(File.separator + "obj" + File.separator + "Debug" + File.separator)) return false;
|
|
87
|
+
if (path.contains(File.separator + "obj" + File.separator + "Release" + File.separator)) return false;
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public boolean acceptFile(String path) {
|
|
92
|
+
List<String> acceptedExtensions = new ArrayList<>(cppExtensions);
|
|
93
|
+
acceptedExtensions.add(javaExtension);
|
|
94
|
+
acceptedExtensions.add(kotlinExtension);
|
|
95
|
+
acceptedExtensions.add(scalaExtension);
|
|
96
|
+
acceptedExtensions.add(groovyExtension);
|
|
97
|
+
acceptedExtensions.add(csExtension);
|
|
98
|
+
return acceptedExtensions.stream().anyMatch(path::endsWith);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private String extension(String filename) {
|
|
102
|
+
int extensionIndex = filename.lastIndexOf(".");
|
|
103
|
+
return (extensionIndex == -1) ? null : filename.substring(extensionIndex).toLowerCase();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package org.dxworks.insider.depext;
|
|
2
|
+
|
|
3
|
+
public class ImportItem {
|
|
4
|
+
String name;
|
|
5
|
+
String attribute;
|
|
6
|
+
|
|
7
|
+
public ImportItem(String _name, String _attribute) {
|
|
8
|
+
name = _name;
|
|
9
|
+
attribute = _attribute;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public ImportItem(String _name) {
|
|
13
|
+
this(_name, "");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public String toString() {
|
|
17
|
+
return attribute.isEmpty() ? name : name + "," + attribute;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package org.dxworks.insider.depext;
|
|
2
|
+
|
|
3
|
+
import java.util.ArrayList;
|
|
4
|
+
import java.util.List;
|
|
5
|
+
import java.util.stream.Collectors;
|
|
6
|
+
|
|
7
|
+
public class ImportResult {
|
|
8
|
+
String filename;
|
|
9
|
+
String language;
|
|
10
|
+
String namespace;
|
|
11
|
+
Integer linesOfCode;
|
|
12
|
+
|
|
13
|
+
List<ImportItem> importedItems;
|
|
14
|
+
|
|
15
|
+
public String toString() {
|
|
16
|
+
if (importedItems.isEmpty())
|
|
17
|
+
return filename + "," + language + "," + namespace + "," + linesOfCode + ",";
|
|
18
|
+
|
|
19
|
+
List<String> importLines = importedItems.stream().map(ImportItem::toString).collect(Collectors.toList());
|
|
20
|
+
|
|
21
|
+
String fileColumns = filename + "," + language + "," + namespace + "," + linesOfCode;
|
|
22
|
+
|
|
23
|
+
List<String> rows = new ArrayList<>();
|
|
24
|
+
|
|
25
|
+
importLines.forEach(importItem -> rows.add(fileColumns + "," + importItem));
|
|
26
|
+
return String.join("\n", rows);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static String header() {
|
|
30
|
+
return "file,language,namespace,#lines,import,import_attribute";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
package org.dxworks.insider.depext;
|
|
2
|
+
|
|
3
|
+
import org.dxworks.insider.InsiderFile;
|
|
4
|
+
|
|
5
|
+
import java.util.ArrayList;
|
|
6
|
+
import java.util.Collections;
|
|
7
|
+
import java.util.List;
|
|
8
|
+
|
|
9
|
+
public class JavastackImportsProcessor extends AbstractImportsProcessor {
|
|
10
|
+
public static int javaCounter = 0;
|
|
11
|
+
public static int kotlinCounter = 0;
|
|
12
|
+
public static int scalaCounter = 0;
|
|
13
|
+
public static int groovyCounter = 0;
|
|
14
|
+
|
|
15
|
+
private final String language;
|
|
16
|
+
|
|
17
|
+
public JavastackImportsProcessor(InsiderFile insiderFile, String language) {
|
|
18
|
+
super(insiderFile);
|
|
19
|
+
|
|
20
|
+
this.language = language;
|
|
21
|
+
|
|
22
|
+
switch (this.language) {
|
|
23
|
+
case "java":
|
|
24
|
+
javaCounter++;
|
|
25
|
+
break;
|
|
26
|
+
case "scala":
|
|
27
|
+
scalaCounter++;
|
|
28
|
+
break;
|
|
29
|
+
case "kotlin":
|
|
30
|
+
kotlinCounter++;
|
|
31
|
+
break;
|
|
32
|
+
case "groovy":
|
|
33
|
+
groovyCounter++;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public static boolean hasFiles() {
|
|
39
|
+
return javaCounter + kotlinCounter + scalaCounter + groovyCounter > 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public static String statistics() {
|
|
43
|
+
List<String> rows = new ArrayList<>();
|
|
44
|
+
if (javaCounter > 0) rows.add(javaCounter + " Java files processed");
|
|
45
|
+
if (kotlinCounter > 0) rows.add(kotlinCounter + " Kotlin files processed");
|
|
46
|
+
if (groovyCounter > 0) rows.add(groovyCounter + " Groovy files processed");
|
|
47
|
+
if (scalaCounter > 0) rows.add(scalaCounter + " Scala files processed");
|
|
48
|
+
|
|
49
|
+
return String.join("\n", rows);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Override
|
|
53
|
+
protected String namespaceLine(String trimmedLine) {
|
|
54
|
+
return trimmedLine.startsWith("package") ? trimmedLine.substring(8).trim().replaceAll(";", "") : null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Override
|
|
58
|
+
protected String language() {
|
|
59
|
+
return language;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Override
|
|
63
|
+
protected List<ImportItem> importLine(String trimmedLine) {
|
|
64
|
+
if (!trimmedLine.startsWith("import ")) return null;
|
|
65
|
+
|
|
66
|
+
if (trimmedLine.contains("(")) return null;
|
|
67
|
+
if (trimmedLine.contains("=>")) return null;
|
|
68
|
+
|
|
69
|
+
String attribute = "";
|
|
70
|
+
if (trimmedLine.startsWith("import static ")) {
|
|
71
|
+
trimmedLine = trimmedLine.substring(14);
|
|
72
|
+
attribute = "static";
|
|
73
|
+
} else trimmedLine = trimmedLine.substring(7);
|
|
74
|
+
|
|
75
|
+
trimmedLine = trimmedLine.trim().replaceAll(";", "").replace("}", "").replace("`", "").replace("._", "");
|
|
76
|
+
|
|
77
|
+
String[] parts = trimmedLine.split("\\{");
|
|
78
|
+
if (parts.length == 1) return Collections.singletonList(new ImportItem(trimmedLine, attribute));
|
|
79
|
+
|
|
80
|
+
String prefix = parts[0];
|
|
81
|
+
|
|
82
|
+
String[] listOfImports = parts[1].split(",");
|
|
83
|
+
|
|
84
|
+
List<ImportItem> importItems = new ArrayList<>();
|
|
85
|
+
for (String importItem : listOfImports) new ImportItem((prefix + importItem.trim()), attribute);
|
|
86
|
+
return importItems;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package org.dxworks.insider.depext;
|
|
2
|
+
|
|
3
|
+
import org.dxworks.insider.InsiderFile;
|
|
4
|
+
|
|
5
|
+
import java.util.Collections;
|
|
6
|
+
import java.util.List;
|
|
7
|
+
import java.util.regex.Matcher;
|
|
8
|
+
import java.util.regex.Pattern;
|
|
9
|
+
|
|
10
|
+
class VBImportsProcessor extends AbstractImportsProcessor {
|
|
11
|
+
public static int counter = 0;
|
|
12
|
+
|
|
13
|
+
public VBImportsProcessor(InsiderFile insiderFile) {
|
|
14
|
+
super(insiderFile);
|
|
15
|
+
counter++;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
protected String language() {
|
|
20
|
+
return "visualbasic";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Override
|
|
24
|
+
protected String namespaceLine(String trimmedLine) {
|
|
25
|
+
if (trimmedLine.trim().startsWith("Namespace") == false) return null;
|
|
26
|
+
Pattern p = Pattern.compile("\\s*Namespace\\s([\\w.]+)(.*)");
|
|
27
|
+
Matcher m = p.matcher(trimmedLine.trim());
|
|
28
|
+
return m.find() ? m.group(1) : null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected List<ImportItem> importLine(String trimmedLine) {
|
|
32
|
+
Pattern p = Pattern.compile("Imports\\s([\\w.]+\\s*=*\\s*[\\w.]+)(.*)");
|
|
33
|
+
Matcher m = p.matcher(trimmedLine.trim());
|
|
34
|
+
if (m.find() == false) return null;
|
|
35
|
+
|
|
36
|
+
String[] importedEntity = m.group(1).split("=");
|
|
37
|
+
|
|
38
|
+
if (importedEntity.length == 1) return Collections.singletonList(new ImportItem(importedEntity[0].trim()));
|
|
39
|
+
return Collections.singletonList(new ImportItem(importedEntity[1].trim()));
|
|
40
|
+
}
|
|
41
|
+
}
|