WEBVTT

1
00:00:00.180 --> 00:00:01.290
In this lesson,

2
00:00:01.290 --> 00:00:03.360
we will learn about Scripting.

3
00:00:03.360 --> 00:00:06.941
Scripting in automated security operations refers

4
00:00:06.941 --> 00:00:10.830
to writing code that automates repetitive tasks

5
00:00:10.830 --> 00:00:13.920
and processes, enhancing efficiency

6
00:00:13.920 --> 00:00:17.220
and consistency in security management.

7
00:00:17.220 --> 00:00:21.630
Scripting concepts include pseudocode, data structures,

8
00:00:21.630 --> 00:00:23.550
and control structures.

9
00:00:23.550 --> 00:00:28.200
Pseudocode is a simplified high level version of a script

10
00:00:28.200 --> 00:00:32.910
that outlines the logic and steps needed to perform a task

11
00:00:32.910 --> 00:00:35.640
without focusing on syntax.

12
00:00:35.640 --> 00:00:39.480
Next, data structures such as arrays, lists,

13
00:00:39.480 --> 00:00:43.410
and dictionaries are used within scripts to organize

14
00:00:43.410 --> 00:00:45.570
and manage data efficiently,

15
00:00:45.570 --> 00:00:49.440
allowing the script to process and store information.

16
00:00:49.440 --> 00:00:52.500
Finally, control structures like loops

17
00:00:52.500 --> 00:00:56.040
and conditional statements direct the flow of the script,

18
00:00:56.040 --> 00:00:58.080
enabling it to make decisions

19
00:00:58.080 --> 00:01:02.040
and repeat actions based on specific conditions.

20
00:01:02.040 --> 00:01:05.760
Let's learn more about pseudocode, data structures

21
00:01:05.760 --> 00:01:08.070
and control structures.

22
00:01:08.070 --> 00:01:10.380
First, we have pseudocode.

23
00:01:10.380 --> 00:01:13.530
Think of pseudocode like creating a rough sketch

24
00:01:13.530 --> 00:01:15.360
before building a house.

25
00:01:15.360 --> 00:01:16.440
With a rough sketch,

26
00:01:16.440 --> 00:01:20.100
you don't worry about the exact measurements, materials,

27
00:01:20.100 --> 00:01:22.140
or technical details yet,

28
00:01:22.140 --> 00:01:24.780
you just map out the overall structure

29
00:01:24.780 --> 00:01:26.730
and layout of the house.

30
00:01:26.730 --> 00:01:30.510
This sketch allows you to visualize where the rooms will be,

31
00:01:30.510 --> 00:01:32.460
how the spaces will connect,

32
00:01:32.460 --> 00:01:34.680
and what the flow will look like.

33
00:01:34.680 --> 00:01:37.980
Similarly, pseudocode outlines the steps

34
00:01:37.980 --> 00:01:40.950
and logic of a program without getting

35
00:01:40.950 --> 00:01:42.930
into the technicalities

36
00:01:42.930 --> 00:01:46.290
of any specific scripting language syntax.

37
00:01:46.290 --> 00:01:50.250
So pseudocode gives you a clear sense of direction

38
00:01:50.250 --> 00:01:54.390
before diving into the actual coding process.

39
00:01:54.390 --> 00:01:57.840
Pseudocode serves as a blueprint for scripting,

40
00:01:57.840 --> 00:02:00.120
providing a structured outline

41
00:02:00.120 --> 00:02:03.510
of a program's logic without getting bogged down

42
00:02:03.510 --> 00:02:07.950
by that specific syntax or any technical details.

43
00:02:07.950 --> 00:02:09.270
It's a great way

44
00:02:09.270 --> 00:02:13.380
to break down complex tasks into manageable steps,

45
00:02:13.380 --> 00:02:16.590
making it easier to plan the flow of a script

46
00:02:16.590 --> 00:02:19.830
before diving into the actual coding.

47
00:02:19.830 --> 00:02:22.500
In automated security operations,

48
00:02:22.500 --> 00:02:26.970
pseudocode is especially useful in the design phase.

49
00:02:26.970 --> 00:02:28.020
For instance,

50
00:02:28.020 --> 00:02:32.520
before automating a task such as scanning network traffic

51
00:02:32.520 --> 00:02:36.060
for anomalies, pseudocode can outline the sequence

52
00:02:36.060 --> 00:02:38.280
of steps required, helping you think

53
00:02:38.280 --> 00:02:40.230
through the logic, conditions

54
00:02:40.230 --> 00:02:43.560
and actions necessary to achieve your goal.

55
00:02:43.560 --> 00:02:46.890
The simplicity of pseudocode also makes it easier

56
00:02:46.890 --> 00:02:50.670
to communicate the overall process with team members

57
00:02:50.670 --> 00:02:52.590
who may not be as familiar

58
00:02:52.590 --> 00:02:55.140
with specific scripting languages.

59
00:02:55.140 --> 00:02:58.170
Using pseudocode is particularly important

60
00:02:58.170 --> 00:02:59.760
in security scripting,

61
00:02:59.760 --> 00:03:02.340
where complex automation tasks

62
00:03:02.340 --> 00:03:05.490
like detecting unusual user behaviors

63
00:03:05.490 --> 00:03:08.246
or automating firewall configurations

64
00:03:08.246 --> 00:03:12.870
require a solid plan before implementation.

65
00:03:12.870 --> 00:03:15.060
So by using pseudocode,

66
00:03:15.060 --> 00:03:18.570
you ensure that each step is well thought out

67
00:03:18.570 --> 00:03:21.960
and that no key processes are overlooked.

68
00:03:21.960 --> 00:03:25.980
This also allows room for flexibility and revisions

69
00:03:25.980 --> 00:03:28.800
before committing to actual code,

70
00:03:28.800 --> 00:03:33.330
reducing the likelihood of errors when the scripting begins.

71
00:03:33.330 --> 00:03:36.540
In the end, pseudocode acts as a translator

72
00:03:36.540 --> 00:03:40.140
between human logic and machine execution.

73
00:03:40.140 --> 00:03:42.720
It helps define what needs to happen.

74
00:03:42.720 --> 00:03:44.730
And once the logic is clear,

75
00:03:44.730 --> 00:03:48.390
the actual coding process becomes much smoother.

76
00:03:48.390 --> 00:03:51.030
While it is not executable script,

77
00:03:51.030 --> 00:03:53.280
pseudocode ensures the flow

78
00:03:53.280 --> 00:03:57.450
of executable code will be structured and logical.

79
00:03:57.450 --> 00:04:00.150
Second, we have data structures.

80
00:04:00.150 --> 00:04:04.230
Think about scripting data structures like closets, shelves,

81
00:04:04.230 --> 00:04:06.960
and storage units inside your house.

82
00:04:06.960 --> 00:04:09.540
Just like you need drawers for utensils,

83
00:04:09.540 --> 00:04:12.780
closets for clothes, and cabinets for dishes,

84
00:04:12.780 --> 00:04:15.780
scripting data structures helps you organize

85
00:04:15.780 --> 00:04:18.840
and store information in an orderly way

86
00:04:18.840 --> 00:04:21.360
for use in your code or script.

87
00:04:21.360 --> 00:04:25.170
Whether you are using an array to keep a list of items

88
00:04:25.170 --> 00:04:27.780
or a dictionary to store information

89
00:04:27.780 --> 00:04:29.700
that comes in key-value pairs,

90
00:04:29.700 --> 00:04:32.550
data structures provide an organized way

91
00:04:32.550 --> 00:04:36.090
to manage the information your script needs to handle.

92
00:04:36.090 --> 00:04:37.650
Without data structures,

93
00:04:37.650 --> 00:04:40.530
your data would be scattered all over the place,

94
00:04:40.530 --> 00:04:44.190
making it difficult to access and use efficiently.

95
00:04:44.190 --> 00:04:47.580
Common data structures include arrays, lists,

96
00:04:47.580 --> 00:04:51.180
and dictionaries, each of which handle collections

97
00:04:51.180 --> 00:04:54.270
of information that scripts need to process.

98
00:04:54.270 --> 00:04:55.860
For example, arrays

99
00:04:55.860 --> 00:04:59.340
or lists are used to store a sequence of data

100
00:04:59.340 --> 00:05:02.220
such as IP addresses, log entries,

101
00:05:02.220 --> 00:05:05.100
or the results of a security scan.

102
00:05:05.100 --> 00:05:07.470
Once stored in data structures,

103
00:05:07.470 --> 00:05:10.290
a script can then easily access, update,

104
00:05:10.290 --> 00:05:12.330
or iterate over the data

105
00:05:12.330 --> 00:05:15.330
performing tasks like checking for anomalies

106
00:05:15.330 --> 00:05:17.340
or generating reports.

107
00:05:17.340 --> 00:05:21.720
So data structures ensure that information is processed

108
00:05:21.720 --> 00:05:25.020
in a way that's both logical and efficient.

109
00:05:25.020 --> 00:05:28.096
Different types of data structures are suited

110
00:05:28.096 --> 00:05:29.779
for different tasks.

111
00:05:29.779 --> 00:05:33.270
Arrays and lists allow for ordered collections

112
00:05:33.270 --> 00:05:36.900
where each element can be accessed based on its position

113
00:05:36.900 --> 00:05:38.730
in the array or list.

114
00:05:38.730 --> 00:05:41.310
This makes them ideal for scenarios

115
00:05:41.310 --> 00:05:43.800
where the order of the data matters,

116
00:05:43.800 --> 00:05:46.710
such as in times stamped log files.

117
00:05:46.710 --> 00:05:50.070
Dictionaries, on the other hand, are more flexible,

118
00:05:50.070 --> 00:05:54.030
allowing data to be stored as key-value pairs.

119
00:05:54.030 --> 00:05:56.670
A key-value pair is a data structure

120
00:05:56.670 --> 00:05:58.950
where each unique key is associated

121
00:05:58.950 --> 00:06:01.200
with a specific value allowing

122
00:06:01.200 --> 00:06:04.530
for efficient data retrieval based on the key.

123
00:06:04.530 --> 00:06:06.690
This is particularly useful

124
00:06:06.690 --> 00:06:11.100
when associating specific identifiers like IP addresses

125
00:06:11.100 --> 00:06:14.640
with their corresponding statuses, making it easier

126
00:06:14.640 --> 00:06:18.780
for the script to retrieve data based on a given key.

127
00:06:18.780 --> 00:06:22.950
So the use of appropriate data structures ensures

128
00:06:22.950 --> 00:06:26.700
that scripts handle data in a way that's both optimal

129
00:06:26.700 --> 00:06:29.130
and organized, which is essential

130
00:06:29.130 --> 00:06:31.080
for maintaining the efficiency

131
00:06:31.080 --> 00:06:33.960
of automated security processes.

132
00:06:33.960 --> 00:06:37.530
Third and last, we have control structures.

133
00:06:37.530 --> 00:06:39.870
Think of scripting control structures

134
00:06:39.870 --> 00:06:43.260
like the traffic signals and signs in a city.

135
00:06:43.260 --> 00:06:47.310
These signals and signs direct where cars should go, stop

136
00:06:47.310 --> 00:06:48.750
or take a different route

137
00:06:48.750 --> 00:06:51.750
depending upon the conditions of the road.

138
00:06:51.750 --> 00:06:54.570
In scripting, control structures like loops

139
00:06:54.570 --> 00:06:57.660
and conditional statements guide the logical flow

140
00:06:57.660 --> 00:06:58.560
of your script,

141
00:06:58.560 --> 00:07:02.070
determining when certain actions should be repeated

142
00:07:02.070 --> 00:07:05.160
or when specific decisions should be made.

143
00:07:05.160 --> 00:07:09.210
So just as green lights tell cars to move forward

144
00:07:09.210 --> 00:07:11.580
and red lights tell them to stop,

145
00:07:11.580 --> 00:07:13.860
control structures guide your script

146
00:07:13.860 --> 00:07:16.110
through different pathways and decisions,

147
00:07:16.110 --> 00:07:18.090
ensuring it flows smoothly

148
00:07:18.090 --> 00:07:21.720
and reacts appropriately to the data it encounters.

149
00:07:21.720 --> 00:07:25.740
Control structures play a key role in defining the logic

150
00:07:25.740 --> 00:07:27.510
and flow of a script.

151
00:07:27.510 --> 00:07:29.520
These structures include loops

152
00:07:29.520 --> 00:07:31.260
and conditional statements,

153
00:07:31.260 --> 00:07:33.840
which allow a script to make decisions

154
00:07:33.840 --> 00:07:37.650
and repeat tasks based on certain criteria.

155
00:07:37.650 --> 00:07:39.570
For instance, a common use

156
00:07:39.570 --> 00:07:43.620
of control structures in security automation might involve

157
00:07:43.620 --> 00:07:45.540
iterating over log files

158
00:07:45.540 --> 00:07:49.560
or network packets to scan for suspicious activity.

159
00:07:49.560 --> 00:07:51.480
A loop would allow the script

160
00:07:51.480 --> 00:07:55.440
to check each entry systematically and individually.

161
00:07:55.440 --> 00:07:57.990
While conditional statements would enable it

162
00:07:57.990 --> 00:08:01.350
to take different actions during each entry check,

163
00:08:01.350 --> 00:08:03.510
depending on what it finds.

164
00:08:03.510 --> 00:08:07.440
So in this way, structures enable building scripts

165
00:08:07.440 --> 00:08:09.780
that adapt to varying conditions

166
00:08:09.780 --> 00:08:14.310
and handle different scenarios without manual intervention.

167
00:08:14.310 --> 00:08:18.210
Loops, such as "for" loops or "while" loops

168
00:08:18.210 --> 00:08:20.760
allow scripts to repeat actions,

169
00:08:20.760 --> 00:08:24.810
which is especially useful when dealing with large data sets

170
00:08:24.810 --> 00:08:26.850
or recurring tasks.

171
00:08:26.850 --> 00:08:30.720
For example, a loop could be used to scan through thousands

172
00:08:30.720 --> 00:08:34.710
of login attempts, flagging any that appear suspicious.

173
00:08:34.710 --> 00:08:37.200
By automating these repetitive tasks,

174
00:08:37.200 --> 00:08:40.110
control structures save significant time

175
00:08:40.110 --> 00:08:42.210
and reduce human error.

176
00:08:42.210 --> 00:08:44.910
Next, conditional statements like "if"

177
00:08:44.910 --> 00:08:48.660
and "else" enhance automation by allowing the script

178
00:08:48.660 --> 00:08:52.350
to make decisions based on the data it encounters.

179
00:08:52.350 --> 00:08:57.030
For example, if a systems disc usage exceeds 90%,

180
00:08:57.030 --> 00:09:00.480
the script could automatically clear temporary files

181
00:09:00.480 --> 00:09:02.610
or send an alert adding a layer

182
00:09:02.610 --> 00:09:06.360
of automated decision making into the process.

183
00:09:06.360 --> 00:09:08.130
So remember,

184
00:09:08.130 --> 00:09:11.490
scripting in automated security operations

185
00:09:11.490 --> 00:09:13.860
helps streamline repetitive tasks,

186
00:09:13.860 --> 00:09:18.450
making security processes more efficient and consistent.

187
00:09:18.450 --> 00:09:22.020
First, pseudocode allows you to outline the steps

188
00:09:22.020 --> 00:09:23.850
and logic of a script

189
00:09:23.850 --> 00:09:26.970
without worrying about the technical details,

190
00:09:26.970 --> 00:09:30.540
making the planning phase smoother and clearer.

191
00:09:30.540 --> 00:09:35.100
Next, data structures such as arrays and dictionaries,

192
00:09:35.100 --> 00:09:38.160
organize and manage data in a way

193
00:09:38.160 --> 00:09:40.290
that allows the script to process

194
00:09:40.290 --> 00:09:43.050
and store information efficiently.

195
00:09:43.050 --> 00:09:46.200
And finally, control structures like loops

196
00:09:46.200 --> 00:09:49.530
and conditional statements, guide the scripts flow,

197
00:09:49.530 --> 00:09:51.510
allowing it to make decisions

198
00:09:51.510 --> 00:09:54.990
and repeat tasks based on specific conditions

199
00:09:54.990 --> 00:09:58.863
enhancing the automation of security tasks.

