Table of contents
1.
Introduction
2.
Syntax for windows_defender_exclusion
2.1.
Example
3.
Action
4.
Properties
5.
Common properties
6.
Notification
7.
Guard
7.1.
Properties
8.
Frequently Asked Questions
8.1.
What is a window defender?
8.2.
What is the role of extensions in the window_defender_exlusion resource?
8.3.
Can we set the timer for the notification?
8.4.
What if we don't declare the type of action in window_defender_exlusion?
8.5.
What is the ruby type for properties in window_defender_exlusion resource?
9.
Conclusion
Last Updated: Mar 27, 2024
Medium

CHEF- RESOURCES windows_defender_exclusion Resource

Author dhananjay
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

In this blog, you will learn about window_defender_exlusion, a resource in Chef. The role of  window_defender_exlusion is to declare which paths, processes, or files will not be available during the protection scanning by windows defender.

We will learn how to create these  window_defender_exlusion scripts to exclude the paths, extensions, and processes.

windows_defender_exclusion Resource

 

Syntax for windows_defender_exclusion

windows_defender_exclusion 'name' do
  extensions         String, Array # default value: []
  paths              String, Array # default value: []
  process_paths      String, Array # default value: []
  action             Symbol # defaults to: add if not specified
end

Above is the correct syntax to create the script. 

  • Window_defender_exlusion is one of the resources in chef.
  • Write the name for the resource in the ‘name’ tag.
  • The above example's extensions, paths, and process_pathts are the properties available in window_defender_exlusion.
  • In action, we declare what operation the should chef infra client perform to bring the node to the intended state.

Example

windows_defender_exclusion 'exclude the following things' do
  paths 'c:\example\folder, d:\example1\folder1’'
  extensions ' ppt, doc'
  process_paths 'c:\windows\root’'
  action :add
end

Action

This section describes all available actions for the window_defender_exlusion resource.

  • :add - It is the default action.
  • :nothing - This action will let the resource until it gets confirmation from the other resource. Once it gets notified, it might run or queue for the run.
  • :remove - This action removes the resource.

Properties

Now we will discuss the properties available in the window_defender_exlusion resource

  • paths - To exclude file or directory paths from scanning. Paths ruby type is String, array, and the default is [ ].
  • extensions - To exclude file extensions from scanning. Extensions ruby type is String, array, and the default is [ ].
  • process_paths - To exclude process paths from scanning. Process paths ruby type is String, array, and the default is [ ].

Common properties

Some common properties we can apply to available resources in chef infra client.

  • ignore_fiaiure - To ignore a failure.
  • retires - To catch a number of exceptions and retry resources.
  • retry_delay - Add’s delay during the execution.
  • sensitive - To check if the chef infra client logs in sensitive data.
  • Compile_time - Control the stage of the node's resource execution.

Notification

Type of notification methods we can use in the scripts.

notifies: notifies let you notify another resource to take action if there is a change in its state.

Syntax:

notifies :action, 'resource[name]', :timer

Just specify an action, resource name, and time for the notification.

Types of timer:

  • :before - It notify to execute an action in a resource before processing.
  • :delayed - It notify to queued and run at the end.
  • :immediate and :immediately - It notifies to run immediately.


subscribe: This lets the resource listen to a particular resource and works if there is a change in the state of the listening resource.

Syntax:

subscribe :action, 'resource[name]', :timer

Just specify an action, resource name, and time for the notification.

Types of timer:

  • :before - It notify to execute an action in a resource before processing.
  • :delayed - It notify to queued and run at the end.
  • :immediate and :immediately - It notifies to run immediately.

Guard

  • During the execution stage of a Chef Infra Client run, the condition of a node can be assessed using a guard property. 
  • A guard property is then used to inform Chef Infra Client whether it should keep running a resource in response to the findings of this assessment.
  •  A Ruby block value and a string value are acceptable values for a guard property.

Properties

not_if - to stop the execution if the given condition is true.

only_if - to execute a resource if the condition is true.

Frequently Asked Questions

What is a window defender?

A window defender is a system software to protect from malware.

What is the role of extensions in the window_defender_exlusion resource?

The extensions let you declare what type of file extensions, for ex: png, we should exclude in protection scanning.

Can we set the timer for the notification?

Yes, we can set the notification according to our need using :before, :delayed, and :immediately tag.

What if we don't declare the type of action in window_defender_exlusion?

The default value for action is :add.

What is the ruby type for properties in window_defender_exlusion resource?

String and array is the type for window_defender_exlusion properties.

Conclusion

In this blog, we learned about one of the resources, window_defender_exlusion, available in chef. We discussed the syntax of window_defender_exlusion and various properties and actions available for the window_defender_exlusion resource.

To learn more about chefs, check out the articles given below:

CHEF- RESOURCES -windows_defender Resource

CHEF RESOURCES -windows_password_policy Resource

CHEF RESOURCES -windows_desktop_winrm_settings Resource

CHEF- RESOURCES -rescue_account Resource

To learn more about DSA, competitive coding, and many more knowledgeable topics, please look into the guided paths on Coding Ninjas Studio. Also, you can enroll in our courses and check out the mock test and problems available to you. Please check out our interview experiences and interview bundle for placement preparations.

Live masterclass