Micorosoft が、
microsoft/ApplicationInspector: A source code analyzer built for surfacing features of interest and other characteristics to answer the question ‘what’s in it’ using static analysis with a json based rules engine. Ideal for scanning components before use or detecting feature level changes. と
前提
- OS の
バージョン sw_vers ProductName: Mac OS X ProductVersion: 10.14.6 BuildVersion: 18G2022
インストール、 実行
インストール、
インストール
Github の
* Releases · microsoft/ApplicationInspector
私がダウンロードした
ApplicationInspector_macos_1.0.24.zip
ダウンロードした フォルダを 移動する
Downloads ディレクトリに
これは、
mv /Users/xxxxx/Downloads/ApplicationInspector_1.0.24 /Users/xxxxx/Programing/Tools/
実行
ディレクトリ移動
インストールディレクトリに移動します。 cd /Users/xxxxx/Programing/Tools/ApplicationInspector_1.0.24/
コマンドを
実行
試しに手元に あった Javaの Mavenプロジェクトに 対して、 AppInspectorを 実行してみました。 ちなみに、./AppInspector analyze -s /Users/xxxxx/Programing/Bitbucket/festivals4partypeople_java/
srcフォルダではなく pom.xmlの ある プロジェクトルートを 指定しています。
srcフォルダを指定した 場合は、 エラーにはなりませんでしたが、 上手く 動きませんでした。
ツールを実行すると 以下の ログが コンソールに 出力されます。 完了すると、Microsoft Application Inspector 1.0.24 Analyze command running 8% source files processedDecompressing files... 100% source files processed Preparing report Opening default browser to output.html report Analyze command completed
自動で ブラウザが 起動し、 以下の 画面が 表示されます。
ApplicationInspector の コマンドの 説明
ApplicationInspector/README.md at master · microsoft/ApplicationInspector を
Analyze
ソースコードの解析を 実行する コマンドです。 Tagdiff
ソースコードをbefore、 after で 指定し before、 after 間での 警告の 差分を 比較できます。 TagTest
ソースコードに指定した ルールの 警告が 出力されないか チェックできます。
デフォルトのルールで チェックできるか 試してみましたが、 カスタムルールを 指定しないと エラーに なります。 カスタムルールの./AppInspector tagtest -s /Users/xxxxx/Programing/Bitbucket/festivals4partypeople_java/ Microsoft Application Inspector 1.0.24 No rules specified. At least one valid rules path required.. Please see log file for more information.
作り方は Home · microsoft/ApplicationInspector Wiki に 記載されているのと、 デフォルトルールファイルは、 ApplicationInspector/AppInspector/rules/default at master · microsoft/ApplicationInspector 配下に jsonファイル格納されているので、 それらを 参考に すれば 作成は できそうに 思います。 ExportTags
タグの一覧が 出力できる コマンドです。 出力される ファイルは ルールファイルでは ありません。
オプション指定なしで実行すると、 デフォルトルールの 一覧が 出力できます。 ./AppInspector exporttags Microsoft Application Inspector 1.0.24 Exporttags command running Authentication.General Authentication.Google Authentication.HTMLForm Authentication.JWT Authentication.LDAP Authentication.Microsoft.Online Authentication.Microsoft.Windows.ActiveDirectory Authentication.Microsoft.Windows.Kerberos Authentication.Microsoft.Windows.NTLM Authentication.Oauth Authentication.OpenIDConnect Authentication.SAML Authorization.Claims Authorization.General Authorization.Microsoft.Azuze.SAS Authorization.Permissions Authorization.RBAC CloudServices.AdvertisingNetwork.Google.Adsense CloudServices.AdvertisingNetwork.Microsoft.BingAds CloudServices.AdvertisingNetwork.Outbrain CloudServices.Application.Microsoft.O365 CloudServices.Application.Microsoft.Telemetry CloudServices.Application.SendGrid.Mail CloudServices.BigData.Analytics.DataBricks CloudServices.DataStorage.Amazon.S3 CloudServices.DataStorage.DropBox CloudServices.DataStorage.Google.Drive CloudServices.DataStorage.MediaFire CloudServices.DataStorage.Microsoft.Azure CloudServices.DataStorage.Microsoft.AzureKeyVault CloudServices.DataStorage.Microsoft.OneDrive CloudServices.DataStorage.PasteBin CloudServices.Finance.eCommerce CloudServices.Hosting.Microsoft.Azure CloudServices.SocialMedia.Facebook CloudServices.SocialMedia.Instagram CloudServices.SocialMedia.Misc CloudServices.SocialMedia.Twitter CloudServices.SocialMedia.YouTube CloudServices.Web.Analytics.Facebook CloudServices.Web.Analytics.Google.GTag CloudServices.Web.Analytics.Microsoft.Bing CloudServices.Web.Analytics.Outbrain CloudServices.Web.Analytics.Pinterest CloudServices.Web.Analytics.Twitter Component.Executable.Adobe.Flash Component.Executable.Adobe.PDF Component.Executable.Microsoft.ActiveX Component.Executable.Microsoft.COM Component.Executable.Microsoft.DLL Component.Executable.Microsoft.Silverlight Cryptography.Cipher.3DES Cryptography.Cipher.AES Cryptography.Cipher.CipherMode Cryptography.Cipher.RC Cryptography.Cipher.RSA Cryptography.CryptoCurrency Cryptography.Encoding.Base64 Cryptography.Encryption.General Cryptography.HashAlgorithm.General Cryptography.HashAlgorithm.Legacy Cryptography.HashAlgorithm.Misc Cryptography.HashAlgorithm.Other Cryptography.HashAlgorithm.PBKDF1 Cryptography.HashAlgorithm.SHA2 Cryptography.HashAlgorithm.SHA3 Cryptography.Implementation Cryptography.Implementation.MD5 Cryptography.Implementation.SHA1 Cryptography.Implementation.SHA256 Cryptography.KeyDerivation.General Cryptography.KeyDerivation.PBKDF1 Cryptography.KeyDerivation.PBKDF2 Cryptography.Library.Microsoft.NET Cryptography.Library.TLS.BoringSSL Cryptography.Library.TLS.BouncyCastle Cryptography.Library.TLS.LibreSSL Cryptography.Library.TLS.mbedTLS Cryptography.Library.TLS.OpenSSL Cryptography.Library.Win32 Cryptography.Protocol.KeyExchange Cryptography.Protocol.SSH Cryptography.Protocol.TLS Cryptography.Protocol.TLS.WeakSSL Cryptography.Randomness.PRNG Cryptography.Signing.Code Cryptography.Signing.Data Cryptography.X509Certificates.ClientAuth Cryptography.X509Certificates.Create Cryptography.X509Certificates.Keyfile Cryptography.X509Certificates.Use Data.DBMS.Connection.ODBC Data.DBMS.General Data.DBMS.NoSQL Data.DBMS.ORM.Django Data.DBMS.ORM.SQLAlchemy Data.DBMS.PostgreSQL Data.DBMS.SQL Data.DBMS.SQL.ADO Data.DBMS.SQL.Oracle Data.DBMS.SQLite Data.Deserialization Data.Deserialization.Signal.Bluetooth Data.Deserialization.Signal.Cellular Data.Deserialization.Signal.Ethernet Data.Deserialization.Signal.Modem Data.Deserialization.Signal.USB Data.Media.Audio Data.Media.Video Data.Parsing.JSON Data.Parsing.Media Data.Parsing.XML Data.Parsing.XSLT Data.Sensitive.Credentials Data.Sensitive.Financial.BankAccount Data.Sensitive.Financial.CreditCard Data.Sensitive.Financial.Currency Data.Sensitive.Financial.General Data.Sensitive.Financial.Payroll Data.Sensitive.Financial.Salesdata Data.Sensitive.Identification Data.Sensitive.Medical Data.Sensitive.ProductKey Data.Sensitive.Secret Data.Sensitive.UserAccount Data.Serialization Data.Zipfile Dependency.SourceInclude Framework.CMS.Drupal Framework.CMS.Joomla Framework.CMS.Sharepoint Framework.CMS.Wordpress Framework.Development.AngularJS Framework.Development.ApacheStruts Framework.Development.ApacheTapestry Framework.Development.Aurelia Framework.Development.Backbone Framework.Development.Blade Framework.Development.Bottle Framework.Development.CherryPy Framework.Development.CubicWeb Framework.Development.Django Framework.Development.DropWizard Framework.Development.EmberJS Framework.Development.Flask Framework.Development.Giotto Framework.Development.Google.API Framework.Development.Grails Framework.Development.GWT Framework.Development.Hibernate Framework.Development.JHipster Framework.Development.jQuery Framework.Development.JSF Framework.Development.Library.Boost Framework.Development.Library.StandardC Framework.Development.Logging.Log4j Framework.Development.Logging.Log4Net Framework.Development.Logging.NLog Framework.Development.Logging.Serilog Framework.Development.Logging.ULog Framework.Development.Logging.Winston Framework.Development.Meteor Framework.Development.Microsoft.ADO Framework.Development.Microsoft.Azure Framework.Development.Microsoft.COM Framework.Development.Microsoft.Linq Framework.Development.Microsoft.MFC Framework.Development.Microsoft.Mono Framework.Development.Microsoft.NET.ASP Framework.Development.Microsoft.NETCore Framework.Development.Microsoft.NETStandard Framework.Development.Microsoft.Server.Dynamics Framework.Development.Microsoft.Server.Exchange Framework.Development.Microsoft.Server.IIS Framework.Development.Microsoft.WCF Framework.Development.Microsoft.WindowsSDK Framework.Development.Mithril Framework.Development.MyBatis Framework.Development.OWL Framework.Development.PHP Framework.Development.PlayFramework Framework.Development.Polymer Framework.Development.PrimeFaces Framework.Development.Pryamid Framework.Development.Pylons Framework.Development.Rails Framework.Development.RDF Framework.Development.React Framework.Development.Redux Framework.Development.Redux-Saga Framework.Development.RITEWay Framework.Development.RQL Framework.Development.Sanic Framework.Development.Spark Framework.Development.Spring Framework.Development.Tornado Framework.Development.TurboGears Framework.Development.Vaadin Framework.Development.Vertx Framework.Development.Vue Framework.Development.Web2Py Framework.Development.Wicket Framework.Testing.AceUnit Framework.Testing.Andit Framework.Testing.Arquillian Framework.Testing.Artos Framework.Testing.AssertJ Framework.Testing.AutoTest Framework.Testing.Autounit Framework.Testing.Ava Framework.Testing.Bacon Framework.Testing.BeanSpec Framework.Testing.BeanTest Framework.Testing.Boost Framework.Testing.BugEye Framework.Testing.BusterJS Framework.Testing.Cactus Framework.Testing.Catch Framework.Testing.Catch2 Framework.Testing.Catsrunner Framework.Testing.Cedar Framework.Testing.Cfix Framework.Testing.Cgreen Framework.Testing.Chai Framework.Testing.Concordion Framework.Testing.Concutest Framework.Testing.Crosscheck Framework.Testing.Cucumber Framework.Testing.Cuppa Framework.Testing.DbUnit Framework.Testing.Doctest Framework.Testing.DOH Framework.Testing.EasyMock Framework.Testing.EnhanceJS Framework.Testing.Eryn Framework.Testing.EtlUnit Framework.Testing.EvoSuite Framework.Testing.fast-check Framework.Testing.FireUnit Framework.Testing.GHUnit Framework.Testing.Gmock Framework.Testing.GrandTestAuto Framework.Testing.GroboUtils Framework.Testing.HavaRunner Framework.Testing.Instinct Framework.Testing.Intern Framework.Testing.J3Unit Framework.Testing.Jasmine Framework.Testing.JasUnit Framework.Testing.JBehave Framework.Testing.JDave Framework.Testing.Jest Framework.Testing.JExample Framework.Testing.JGiven Framework.Testing.JMock Framework.Testing.JMockit Framework.Testing.Jnario Framework.Testing.Js-test-runner Framework.Testing.JSNUnit Framework.Testing.JSpec Framework.Testing.JSSpec Framework.Testing.JSST Framework.Testing.JSTest Framework.Testing.JSTestDriver Framework.Testing.JSUnit Framework.Testing.jsUnitTest Framework.Testing.jsUnity Framework.Testing.JSUS Framework.Testing.Jtest Framework.Testing.Jukito Framework.Testing.JUnit Framework.Testing.JUnitEE Framework.Testing.JWalk Framework.Testing.Kiwi Framework.Testing.Lighttest Framework.Testing.Microtest Framework.Testing.Minitest Framework.Testing.Mocha Framework.Testing.Mockito Framework.Testing.Mockrunner Framework.Testing.Needle Framework.Testing.Nodeunit Framework.Testing.Nose Framework.Testing.NUTester Framework.Testing.ObjcUnit Framework.Testing.OCUnit Framework.Testing.OpenPojo Framework.Testing.Pester Framework.Testing.PowerMock Framework.Testing.PyTest Framework.Testing.quick Framework.Testing.QUnit Framework.Testing.Randoop Framework.Testing.RhinoUnit Framework.Testing.RhUnit Framework.Testing.RSpec Framework.Testing.screw-unit Framework.Testing.Shoulda Framework.Testing.ShouldDSL Framework.Testing.SinonJS Framework.Testing.SOAtest Framework.Testing.Specta Framework.Testing.Spock Framework.Testing.SpryTest Framework.Testing.SureAssert Framework.Testing.Tacinga Framework.Testing.Tape Framework.Testing.Teenytest Framework.Testing.Test.Simple Framework.Testing.TestCase Framework.Testing.testdouble.js Framework.Testing.TestIt Framework.Testing.TestNG Framework.Testing.TestUnit Framework.Testing.TMF Framework.Testing.Tyrtle Framework.Testing.Unitils Framework.Testing.UnitJS Framework.Testing.unittest Framework.Testing.UnitTesting Framework.Testing.Vows Framework.Testing.WallabyJS Framework.Testing.WOTest Framework.Testing.wru Framework.Testing.XCTest Framework.Testing.XMLUnit Framework.Testing.XPyUnit Framework.Testing.YUITest Hardware.Accessory.Microsoft.Kinex Hardware.ReferenceDesign Metadata.Application.Author Metadata.Application.Container.CRI-O Metadata.Application.Container.Docker Metadata.Application.Container.Kubernetes Metadata.Application.Container.Microsoft.Core Metadata.Application.Container.Microsoft.Hyper-V Metadata.Application.Container.rktlet Metadata.Application.Description Metadata.Application.Name Metadata.Application.Output.Type Metadata.Application.Publisher Metadata.Application.Target.Framework Metadata.Application.Target.Processor Metadata.Application.Type.Client.Service.Windows Metadata.Application.Type.Client.Windows Metadata.Application.Type.Client.Winforms Metadata.Application.Type.Web.Application Metadata.Application.Type.Web.Service Metadata.Application.Version Metadata.CloudServices.Code.CI.CircleCI Metadata.CloudServices.Code.CI.Microsoft.Azure Metadata.CloudServices.Code.CI.TravisCI Metadata.CloudServices.Code.Repo.BitBucket Metadata.CloudServices.Code.Repo.GitHub Metadata.CloudServices.Code.Repo.GitLab Metadata.CloudServices.Code.Repo.LaunchPad Metadata.CloudServices.Code.Repo.Microsoft.NuGet Metadata.CloudServices.Code.Repo.NPM Metadata.CloudServices.Code.Repo.PyPI Metadata.CloudServices.Code.Repo.Savannah Metadata.CloudServices.Code.Repo.SourceForge Metadata.CloudServices.Code.Repo.VisualStudio Metadata.CloudServices.Hosting.Amazon.AWS Metadata.CloudServices.Hosting.Apple.iCloud Metadata.CloudServices.Hosting.DigitalOcean Metadata.CloudServices.Hosting.Google Metadata.CloudServices.Hosting.Microsoft.AppStore Metadata.CloudServices.Hosting.Microsoft.Azure Metadata.Development.Build.Ant Metadata.Development.Build.Bamboo Metadata.Development.Build.Gradle Metadata.Development.Build.Grape Metadata.Development.Build.Ivy Metadata.Development.Build.Jenkins Metadata.Development.Build.Leiningen Metadata.Development.Build.Maven Metadata.Development.Build.SBT Metadata.Development.Build.TeamCity Metadata.Development.Build.VisualStudio Metadata.OS.ACL.Write.Unsafe Metadata.Platform.Device.IOT Metadata.Platform.Device.Mobile Metadata.Platform.Microsoft.Mono Metadata.Platform.Microsoft.NETCore Metadata.Platform.Microsoft.NETStandard Metadata.Platform.OS.Apple.iOS Metadata.Platform.OS.Apple.MacOS Metadata.Platform.OS.Google.Android Metadata.Platform.OS.Linux.Distro Metadata.Platform.OS.Microsoft.WindowsCE Metadata.Platform.OS.Microsoft.WindowsServer Metadata.Platform.OS.Microsoft.WindowsStandard Metadata.Platform.OS.Microsoft.WindowsUniversalPlatform Metadata.Platform.OS.Microsoft.XBox Metric.Code.Class.Defined Metric.Code.Exception.Caught Metric.Code.Function.Defined Metric.Code.HTMLForm.Defined Metric.Code.Logging.Call Metric.Code.SampleCode Metric.Code.URL Miscellaneous.CodeHygiene.Comment.Fix Miscellaneous.CodeHygiene.Comment.Suspicious Miscellaneous.CodeHygiene.Comment.Todo Miscellaneous.OpenSourceLicense.Apache Miscellaneous.OpenSourceLicense.BSD Miscellaneous.OpenSourceLicense.CreativeCommons Miscellaneous.OpenSourceLicense.Eclipse Miscellaneous.OpenSourceLicense.GPL Miscellaneous.OpenSourceLicense.LGPL Miscellaneous.OpenSourceLicense.Microsoft Miscellaneous.OpenSourceLicense.MIT Miscellaneous.OpenSourceLicense.Mozilla OS.ACL.Impersonation OS.ACL.TokenImpersonation OS.ACL.Write OS.ACL.Write.AppContainer OS.ACL.Write.Audit OS.ACL.Write.FileSecurity OS.ACL.Write.General OS.ACL.Write.SystemToken. OS.Environment.Windows.RegistryLocation OS.Environment.Write OS.FileOperation.Delete OS.FileOperation.Read OS.FileOperation.Write OS.Network.Connection.Cellular OS.Network.Connection.General OS.Network.Connection.Http OS.Network.Connection.Http.Ajax OS.Network.Connection.Miscellaneous OS.Network.Connection.Modem OS.Network.Connection.RPC OS.Network.Connection.Socket OS.Network.Connection.Tcp OS.Process.DynamicExecution OS.Process.ListRequest OS.Process.Multiprocessing OS.SystemRegistry.ACL OS.SystemRegistry.Read OS.SystemRegistry.Write OS.UserAccount.Write Exporttags command completed
Verify
ルールの妥当性を 検証する コマンドです。
ApplicationInspectorの 使用用途に ついて
少し触ってみて、
ソースコードリーディングを
始める 前に 実行して 概要を 掴む
Githubからライブラリ、 アプリケーションの ソースコードを ダウンロードして、 ApplicationInspector を 実行、 出力される Tags List を 見る ことで、 ライブラリが どのような 機能を 使っているのか 概要が 掴めそうに 思いました。 手元の Javaプロジェクトは、 Dropwizard を 使っていますが、 以下のようなTag が 出力されていました。 ApplicationInspector/java.json at master · microsoft/ApplicationInspector にFramework.Development.DropWizard
Java の フレームワークの ルールファイルが ありますが、 メジャーどころはだいたい 検出してくれるようです。 ソースコードレビュー前に
実行して、 問題が 多そうな 部分を 特定する
ソースコードレビューの物量が 膨大だと どこに パワーを 使うかで 迷います。
Confidence
がHigh
で且つ、 Importance
がCritical
と出力された 箇所を 重点的に 見るのが 良いかと 思います。
SonarQube、PMD、 Findbugs 等との 違いは、 SonarQube、 PMD、 Findbugs が 厳密に ソースコードの 良くない 箇所を 検知するのに 対して、 ApplicationInspectorは もっと 大雑把に、 問題が あるかもしれない 部分を 検知してくれます。
チェックの順番と しては、 SonarQube、 PMD、 Findbugs の チェックを 突破した プログラムに 対して、 ApplicationInspector を 実行するのが 良さそうです。 ライブラリの
責務違反を 検知する
TagTest をCI に 組み込んで カスタムルールを 定義する ことで、 ライブラリの 責務に 反する 処理が 追加された 場合、 ビルドを 失敗させる ことができるかと 思います。
ApplicationInspectorの
現状、
オプションが
以上です。
コメント