A Practical Approach to Constructing a Knowledge Graph for Cybersecurity 阅读笔记

A Practical Approach to Constructing a Knowledge Graph for Cybersecurity 阅读笔记

Article

A Practical Approach to Constructing a Knowledge Graph for Cybersecurity

Background

充分利用各种知识库和网站中与网络安全相关的信息,并将这些信息整合在一起,将有助于入侵检测和网络安全态势感知。

Purpose

作者在本文中主要进行了以下两个方面的工作:

1、讨论了建立网络安全知识库的三个步骤,提出建立知识库的框架,即获取信息、建立本体、生成知识库。

2、讨论了网络安全知识推理,提出一个五元模型(概念,实例,关系,属性,规则),利用路径排序算法获取新知识,

Framework Design

图1描述了建立网络安全知识库的方法,该框架主要包括三个部分:构建数据源、构建本体和抽取相关信息、网络安全知识图谱生成。

在这里插入图片描述

提出了一个网络安全知识库的五元模型,知识库结构如图2所示,包含3个本体:Assets,Vulnerability,Attack。

在这里插入图片描述

图3中展示了网络安全本体。

在这里插入图片描述

训练NER的特征集如下:

UseNGrams,MaxNGramLeng,UsePrev,UseNext,UseWordPirs,UseTaggySequences,UseGazettes,Gazette,CleanGazette,SloppyGazette

Knowledge deduction

属性推理使用现有实例的属性和条件推导新的属性。如“姚明”具有属性“出生日期”,给定当前的时间和姚明的出生日期,可以推算他的年龄。

关系推理根据实例间现有的关系推断新的关系。例如,给定

关系1(李四,出生地,北京)

关系2 (李四,住所,上海)

关系3(北京,属于国家,中国)

关系4(上海,属于国家,中国)

关系5(李四,国籍,中国)

关系6(李四,同学,张三)

关系7(张三,出生地,北京)

可以获得一种新的关系:关系8(张三,国籍,中国)

Attribute deduction

图4中有3个实例 N i N_i Ni N j N_j Nj N l N_l Nl,分别具有对应的key和值。
在这里插入图片描述

属性表示为(node,key,value),预测属性的公式为

 Value  i k = ∑ j = 1 m λ j ⋅ f i j ( k e y j ,  value  j ) + ∑ t = 1 1 σ t ⋅ ∑ j = 1 m λ j ⋅ f i j ( k e y j +  value  j ) \text { Value }_{i k}= \sum_{j=1}^{m} \lambda_{j} \cdot f_{i j}\left(\mathrm{key}_{j}, \text { value }_{j}\right)+\sum_{t=1}^{1} \sigma_{t} \cdot \sum_{j=1}^{m} \lambda_{j} \cdot f_{i j}\left(\mathrm{key}_{j}+\text { value }_{j}\right)  Value ik=j=1mλjfij(keyj, value j)+t=11σtj=1mλjfij(keyj+ value j)

N i N_i Ni的新属性如图5。

在这里插入图片描述

Relationship deduction

常用的关系推理方法有三种:基于低维向量表示的嵌入技术;路径排序算法;概率图模型。本文中作者采用路径排序算法,基本思想是利用连接两个实体的路径作为特征预测实体间的关系。使用给定关系的路径排序算法,可以判断两个实体之间是否存在这样的关系。

在这里插入图片描述

实例 N i N_i Ni N j N_j Nj N l N_l Nl的属性值和关系如图6所示,关系推理的预测公式为:

s c o r e ( l , j ) = ∑ π ∈ Q P a t h [ e l , e j ; l e n g t h ( π ) ≤ n ] ⋅ ω π score(l,j) = \sum_{\pi \in Q}Path[e_l,e_j;length(\pi)\leq n]·\omega_\pi score(l,j)=πQPath[el,ej;length(π)n]ωπ

其中 ω π \omega_\pi ωπ是可达路径的权重,路径长度小于等于n。当 s c o r e ( l , j ) ≥ τ score(l,j)\geq\tau score(l,j)τ时,建立路径即关系 e l j e_{lj} elj。通过此路径排序算法,可以建立新的关系如图7。
在这里插入图片描述

Conclusion

本文构建了网络安全本体,提出了一种网络安全知识库的构建方法。斯坦福NER被用来训练一个提取器来提取与网络安全相关的实体;但识别精度有待进一步提高。此外,还可以通过演绎规则获得新的实体属性和实体之间的新关系。未来最重要的工作是丰富网络安全知识库和推理规则,并将其应用到入侵检测和态势感知的研究中。

Here is a C++ program that constructs a max heap with integers and prints it in the rotated form: ```cpp #include <iostream> #include <vector> using namespace std; // function to swap two integers void swap(int& a, int& b) { int temp = a; a = b; b = temp; } // function to heapify the given vector void heapify(vector<int>& arr, int n, int i) { int largest = i; // initialize largest as root int left = 2*i + 1; // left child index int right = 2*i + 2; // right child index // if left child is larger than root if (left < n && arr[left] > arr[largest]) largest = left; // if right child is larger than largest so far if (right < n && arr[right] > arr[largest]) largest = right; // if largest is not root if (largest != i) { // swap the root with largest element swap(arr[i], arr[largest]); // recursively heapify the affected sub-tree heapify(arr, n, largest); } } // function to build max heap void buildMaxHeap(vector<int>& arr, int n) { // start from the last non-leaf node and heapify each node for (int i = n / 2 - 1; i >= 0; i--) heapify(arr, n, i); } // function to print the heap in the rotated form void printRotatedHeap(vector<int>& arr, int n) { int height = log2(n) + 1; // height of the heap int index = 0; // current index in the heap int spaces = pow(2, height - 1) - 1; // number of spaces before the first element of the current level // print each level of the heap in the rotated form for (int i = 0; i < height; i++) { // print the spaces before the first element of the current level for (int j = 0; j < spaces; j++) cout << " "; // print the elements of the current level for (int j = 0; j < pow(2, i) && index < n; j++) { cout << arr[index++] << " "; // print the spaces between elements of the current level for (int k = 0; k < 2 * spaces + 1; k++) cout << " "; } // move to the next line and adjust the number of spaces for the next level cout << endl; spaces /= 2; } } int main() { int n; cout << "Enter the number of elements: "; cin >> n; vector<int> arr(n); cout << "Enter the elements: "; for (int i = 0; i < n; i++) cin >> arr[i]; // build max heap buildMaxHeap(arr, n); // print the heap in the rotated form cout << "Max heap in the rotated form:\n"; printRotatedHeap(arr, n); return 0; } ``` In this program, we first define a `swap` function to swap two integers, and a `heapify` function to heapify the sub-tree rooted at a given index `i` in the given vector `arr`. We then define a `buildMaxHeap` function to build the max heap from the given vector `arr`. Finally, we define a `printRotatedHeap` function to print the max heap in the rotated form. In the `main` function, we first read the number of elements and the elements themselves from the user using `cin`. We then build the max heap using `buildMaxHeap` function, and print the heap in the rotated form using `printRotatedHeap` function. The `printRotatedHeap` function uses the height of the heap to determine the number of levels, and the number of spaces before the first element of each level. It then prints each level of the heap in the rotated form, by printing the elements of the level followed by the spaces between elements.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值