承接 shiftpi/metascan-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shiftpi/metascan-api

最新稳定版本:v0.1

Composer 安装命令:

composer require shiftpi/metascan-api

包简介

Access to Metascan Online API

README 文档

README

Client for Metascan Online Public API.

Installation

Using Composer

Enable module by adding

// ...
'modules' => [
    // ...
    'ShiftpiMetascanApi',
    // ...
],
// ...

after you have required shiftpi/metascan-api in your composer.json.

Features

What is supported?

  • Scanning files by upload
  • Looking up stored reports for single hashes

What is not supported?

  • Looking up stored reports for multiple hashes
  • Looking up IP addresses or URIs

Configuration

Add

'metascan' => [
    'key' => 'yourapikey'
]

to your application's config. You may want to use another HTTP client adapter. By default CURL is used. To use your own adapter, register ShiftpiMetascanApi\Http\Adapter and make sure it is an instance of Zend\Http\Client\Adapter\AdapterInterface.

Usage

Scan data

If you want to scan the whole content of a file, you should use the ScanService class. Retrieve an instance from the service manager by using the key ShiftpiMetascanApi\Service\Scan.

$service = $sm->get(\ShiftpiMetascanApi\Service\Scan::class);
$result = $service->scan(file_get_contents('/path/to/myfile.zip', 'myfile.zip', 'secretpassword'));

The second and third parameters are optional. If you upload an encrypted archive, Metascan Online can decrypt it if you provide the password as third parameter.

Lookup hash

A faster way checking files is looking up its hash. For that you can use the HashLookupService by retrieving ShiftpiMetascanApi\Service\HashLookup from the service manager.

$service = $sm->get(\ShiftpiMetascanApi\Service\HashLookup::class);
$result = $service->lookup(hash('sha256', file_get_contents('/path/to/myfile.zip')));

The parameter should be a SHA256, SHA1 or MD5 hash. If the parameter has an other string length, than a supported algorithm produces, an exception will be thrown. Please note: If you lookup a hash Metascan does not know, a "Not Found" state will be returned. This does not mean, that the file is probably not malicious.

Testing

There are some test files for the services present. You have to copy the file test/config/config.local.php.dist to test/config/config.local.php and paste your API key in order to run those.
These are tests against the real API, which will produce real API requests (no mocks!). Therefore be careful running them and keep yor API limits in mind. ;-)

License

Licensed under the MIT license. See license file.

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-02