飙血推荐
  • HTML教程
  • MySQL教程
  • JavaScript基础教程
  • php入门教程
  • JavaScript正则表达式运用
  • Excel函数教程
  • UEditor使用文档
  • AngularJS教程
  • ThinkPHP5.0教程

如何使用 Java 代码示例补充 SharePoint 站点驱动器安全性

时间:2023-06-08  作者:电脑狂魔  

全世界有超过 250,000 家公司/组织依靠 SharePoint 来安全地管理他们最有价值的文档,总用户超过 300 万。这种广泛的流行使该平台成为市场领先的文档管理解决方案——这进一步使其成为有动机的威胁参与者的一个有价值的目标。

当然,绕过 SharePoint 的内置安全性是一项极其困难的任务。O365 环境在每个入口点为租户提供强大的保护,从详尽的物理数据中心安全到领先的应用程序安全策略。使用SSL和TLS连接的顶级文件加密可确保用户数据在传输过程中的安全,以及具有独特加密的 BitLocker 磁盘级加密密钥用于保护静态文件。此外,随着受感染的文件上传已成为一种极其常见的攻击媒介,O365 提供了内置的病毒和恶意软件检测策略(以及反网络钓鱼策略和各种额外的电子邮件链接和附件安全措施),可以根据个人进行广泛定制或组织租户的需求。列表还在继续,每个租户的特定订阅级别最终决定了他们内置保护的范围。

然而,与 SharePoint 的可自定义内置安全策略一样强大,没有任何存储平台的策略旨在用作敏感数据的单点保护。与网络安全的任何分支一样,文档存储安全是一个移动的目标,需要无数的解决方案协同工作,共同创建强大的防御措施来抵御不断变化的攻击媒介。换句话说,通过在内置安全策略之上选择性地分层外部安全策略,可以始终改进任何租户的威胁概况。

在本文的其余部分,我将演示一个免费使用的病毒扫描 API 解决方案,该解决方案可以与 SharePoint 站点驱动器实例集成以扫描文件中的病毒、恶意软件和各种非恶意软件内容威胁,工作与 O365 的内置异步扫描一起根除各种文件上传威胁类型。

示范

下面的高级病毒扫描 API 旨在与 SharePoint 的内置可自定义策略一起用作强大的文档存储安全层,直接扫描目标站点驱动器实例中的新文件上传,以获取越来越多的超过 1700 万个病毒和恶意软件签名列表(包括勒索软件、间谍软件、木马等),同时还执行完整内容验证,以识别隐藏在误导性文件名和非法文件扩展名后面的无效文件类型和其他非恶意软件威胁。 

该 API 还允许开发人员在 API 请求正文中针对不需要的文件类型设置自定义限制,因此无论其内容是否合法,都可以检测并彻底删除各种不需要的和具有潜在威胁的文件类型。例如,存储合同文档的站点驱动器可能只需要常见文件类型,如 .DOCX 或 .PDF:将文件限制为这些类型有助于在不影响工作流程效率的情况下最大限度地降低风险。  

下面,我概述了将此 API 与 SharePoint Online 网站驱动器实例集成所需的信息,并且我提供了可立即运行的Java代码示例,以帮助您轻松构建 API 调用。

首先,您需要收集以下 SharePoint 信息以满足 API 请求正文中的强制参数:

  1. 客户端 ID(客户端 ID 访问凭据;可以从 Azure Active Directory 门户获取)

  2. Client Secret (Client Secret 访问凭据;也从 Azure Active Directory 门户获取

  3. SharePoint 域名(即 域名)

  4. 站点 ID(要从中检索和扫描文件的站点驱动器的特定 SharePoint ID)

或者,您还可以收集以下 SharePoint 信息:

  1. 租户 ID(与您的 Azure Active Directory 相关)

  2. 文件路径(站点驱动器中特定文件的路径)

  3. 项目 ID(例如,DriveItem ID)

获得所有必需信息后,您可以通过在 Maven POM 文件中添加以下对存储库的引用来开始客户端 SDK 安装(JitPack 用于动态编译库):

<repositories>
    <repository>
        <id>域名</id>
        <url>https://域名</url>
    </repository>
</repositories>

然后您可以通过添加以下对依赖项的引用来结束:

<dependencies>
<dependency>
    <groupId>域名dmersive</groupId>
    <artifactId>域名</artifactId>
    <version>域名</version>
</dependency>
</dependencies>

此时,您可以添加导入并复制 Java 代码示例来构建您的 API 调用:

// Import classes:
//import 域名域名lient;
//import 域名域名xception;
//import 域名域名iguration;
//import 域名域名.*;
//import 域名域名CloudStorageApi;
ApiClient defaultClient = 域名efaultApiClient();
// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) 域名uthentication("Apikey");
域名piKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//域名piKeyPrefix("Token");
ScanCloudStorageApi apiInstance = new ScanCloudStorageApi();
String clientID = "clientID_example"; // String | Client ID access credentials; see description above for instructions on how to get the Client ID from the Azure Active Directory portal.
String clientSecret = "clientSecret_example"; // String | Client Secret access credentials; see description above for instructions on how to get the Client Secret from the Azure Active Directory portal
String sharepointDomainName = "sharepointDomainName_example"; // String | SharePoint Online domain name, such as 域名
String siteID = "siteID_example"; // String | Site ID (GUID) of the SharePoint site you wish to retrieve the file from
String tenantID = "tenantID_example"; // String | Optional; Tenant ID of your Azure Active Directory
String filePath = "filePath_example"; // String | Path to the file within the drive, such as '域名' or '/folder/subfolder/域名'.  If the file path contains Unicode characters, you must base64 encode the file path and prepend it with 'base64:', such as: 'base64:6ZWV6ZWV6ZWV6ZWV6ZWV6ZWV'.
String itemID = "itemID_example"; // String | SharePoint itemID, such as a DriveItem Id
Boolean allowExecutables = true; // Boolean | Set to false to block executable files (program code) from being allowed in the input file.  Default is false (recommended).
Boolean allowInvalidFiles = true; // Boolean | Set to false to block invalid files, such as a PDF file that is not really a valid PDF file, or a Word Document that is not a valid Word Document.  Default is false (recommended).
Boolean allowScripts = true; // Boolean | Set to false to block script files, such as a PHP files, Python scripts, and other malicious content or security threats that can be embedded in the file.  Set to true to allow these file types.  Default is false (recommended).
Boolean allowPasswordProtectedFiles = true; // Boolean | Set to false to block password protected and encrypted files, such as encrypted zip and rar files, and other files that seek to circumvent scanning through passwords.  Set to true to allow these file types.  Default is false (recommended).
Boolean allowMacros = true; // Boolean | Set to false to block macros and other threats embedded in document files, such as Word, Excel and PowerPoint embedded Macros, and other files that contain embedded content threats.  Set to true to allow these file types.  Default is false (recommended).
Boolean allowXmlExternalEntities = true; // Boolean | Set to false to block XML External Entities and other threats embedded in XML files, and other files that contain embedded content threats. Set to true to allow these file types. Default is false (recommended).
String restrictFileTypes = "restrictFileTypes_example"; // String | Specify a restricted set of file formats to allow as clean as a comma-separated list of file formats, such as .pdf,.docx,.png would allow only PDF, PNG and Word document files.  All files must pass content verification against this list of file formats, if they do not, then the result will be returned as CleanResult=false.  Set restrictFileTypes parameter to null or empty string to disable; default is disabled.
try {
    CloudStorageAdvancedVirusScanResult result = 域名CloudStorageScanSharePointOnlineFileAdvanced(clientID, clientSecret, sharepointDomainName, siteID, tenantID, filePath, itemID, allowExecutables, allowInvalidFiles, allowScripts, allowPasswordProtectedFiles, allowMacros, allowXmlExternalEntities, restrictFileTypes);
    域名tln(result);
} catch (ApiException e) {
    域名tln("Exception when calling ScanCloudStorageApi#scanCloudStorageScanSharePointOnlineFileAdvanced");
    域名tStackTrace();
}

为了满足请求身份验证参数,您需要提供一个免费层 API 密钥,这将允许您每月扫描多达 800 个文件。

在此请求正文中,您可以设置布尔值以针对包含可执行文件、无效文件、脚本、受密码保护的文件、宏、 XML 外部实体、不安全反序列化和 HTML 的文件应用自定义非恶意软件威胁策略,并且您可以提供一个逗号- 参数中可接受的文件类型的分隔列表restrictFileTypes,以禁止不需要的文件扩展名。CleanResult: False任何违反这些政策的文件都将在 API 响应正文中自动收到一个值,该值与分配给包含病毒和恶意软件的文件的值相同。这个想法是在单个请求中实施 360 度内容保护,以便您可以快速删除(或隔离/分析)可能对您的系统构成严重风险的文件。  

下面,我提供了一个完整的示例 API 响应供您参考:

{
  "Successful": true,
  "CleanResult": true,
  "ContainsExecutable": true,
  "ContainsInvalidFile": true,
  "ContainsScript": true,
  "ContainsPasswordProtectedFile": true,
  "ContainsRestrictedFileFormat": true,
  "ContainsMacros": true,
  "VerifiedFileFormat": "string",
  "FoundViruses": [
    {
      "FileName": "string",
      "VirusName": "string"
    }
  ],
  "ErrorDetailedDescription": "string",
  "FileSize": 0,
  "ContentInformation": {
    "ContainsJSON": true,
    "ContainsXML": true,
    "ContainsImage": true,
    "RelevantSubfileName": "string"
  }
}

值得注意的是,无论您选择如何设置自定义威胁规则,包含 JSON、XML 或嵌入图像的文件也会在 API 响应中标记为此类。  

湘ICP备14001474号-3  投诉建议:234161800@qq.com   部分内容来源于网络,如有侵权,请联系删除。