dne-security-code's Issues
when Umbrella mission is done there is a typo: "Umberlla Mission completed!!!" in webex teams
Umbrella Mission TODO's are already done, so it's too easy!!!
Documentation for Module 1 needs to be updated to use Python 3.6 for development host.
Step 3: Set up the Python Virtual Environment
The built-in CentOS RDP host actually needs "python3.6 -m venv venv" rather than "python3 -m venv venv"
AMP unused imports - amp_malware_count.py
not used:
import webexteamssdk
from crayons import blue
ISE non-pythonic code - ise_mission.py
ise_mission.py
In the function ‘post_to_ise’ the payload is created in an extremely non-pythonic way. The nice thing is that there is a function in the code that can do it in a pythonic way: ‘createPayload’ (by the way: the function name is non-PEP8)
Original code
def post_to_ise(maclist, namelist):
#TODO: Create the URL for the PUT request to apply the ANC policy! Hint: Make sure you pass the Auth paramenters for the API call
url = MISSION
env_lab.print_missing_mission_warn(env_lab.get_line())
for items in maclist:
payload = "{\r\n \"OperationAdditionalData\": {\r\n \"additionalData\": [{\r\n \"name\": \"macAddress\",\r\n \"value\": \""+ items + "\"\r\n },\r\n {\r\n \"name\": \"policyName\",\r\n \"value\": \"" + namelist + '"' + "\r\n }]\r\n }\r\n}"
print(json.dumps(payload,sort_keys=True,indent=3))
response = requests.request("PUT", url, data=payload, verify=False, headers=headers)
if(response.status_code == 204):
print("Done!..Applied Quarantine policy to the rogue endpoint...MAC: {0} Threat is now contained....".format(items))
else:
print("An error has ocurred with the following code %(error)s" % {'error': response.status_code})
Proposed code:
Import HTTPBasisAuth
Create the payload with the available function
Change the request call, added json=payload in stead of data=payload and added authentication
from requests.auth import HTTPBasicAuth
def post_to_ise(maclist, namelist):
#TODO: Create the URL for the PUT request to apply the ANC policy! Hint: Make sure you pass the Auth paramenters for the API call
url = MISSION
env_lab.print_missing_mission_warn(env_lab.get_line())
authentication = HTTPBasicAuth(username, password)
for items in maclist:
payload = createPayload(items, namelist)
print(json.dumps(payload, sort_keys=True, indent=3))
response = requests.put(url, json=payload, verify=False, headers=headers, auth=authentication)
if response.status_code == 204:
print("Done!..Applied Quarantine policy to the rogue endpoint...MAC: {0} Threat is now contained....".format(items))
else:
print("An error has ocurred with the following code %(error)s" % {'error': response.status_code})
"response" should be "req" in line 96 of the ISE mission
print("An error has ocurred with the following code %(error)s" % {'error': response.status_code})
typo in learning lab FDM
$ python3 fdm_create_networks.py
should be (otherwise file not found error):
$ python3 fdm_create_network.py
AMP unused imports - amp_mission.py
Unused imports
-->
from inspect import currentframe
FDM API does not work with v1, need to be changed to v3 [line 73]
Replace SPARK_ACCESS_TOKEN and SPARK_ROOM_ID with ACCESS_TOKEN and ROOM_ID
Let's not keep propagating the wrong product name in the code.
Remove refrence to "verify/" folder in readme file
in the table in the readme file, there's a reference to the "verify/" directory. This directory isn't present in the repo (and is probably a remainder from DNE DNA)
AMP unused imports - amp_quey_param.py
Unused imports
--->
import webexteamssdk
from crayons import blue, red
Need solutions branch for the Intro to Python py files
Right now you can't link to https://github.com/CiscoDevNet/dne-security-code/blob/solutions/intro-python/part2/fortune_cookie.py because there's no file on the solutions branch for the intro-python files.
Need to update the README(s)
They are a little boring today and could use some spicing up! Additionally, the contents need to be updated to reflect the v1.1
repo restructuring, coding patterns (use the env_lab.py
and env_user.py
configuration files), and lab/mission workflows.
AMP step 2 JSON pretty print
Lab guide says:
"You should see a print out to the screen that looks similar to the section below: "
followed by JSON in a pretty format with colors
However, the code just outputs one big ugly blob of JSON text.
So either the lab guide needs to be corrected to match the code, or (preferably) the step2.py code needs to be corrected to json.dumps the JSON all pretty.
(thanks to John Frame for pointing it out)
AMP unused var - amp_custom_detect.py
variable "payload" is not used in "def post_to_amp" function
2 typos in umbrella mission
"domin_filter_ip = []" line 137 should be "domain_filter_ip = []"
"markdown=f"Umberlla Mission completed!!! \n\n"" line 206 should be "markdown=f"Umbrella Mission completed!!! \n\n""
directory name standardization
Could we please standardize the directory names?
Some have the "dne-security" prefix, eg dne-security-fdm-code
Some don't, eg amp-code
Can we please pick one or the other, and stick to it?
Thank you
threat grid mission line 38 "import env_lab" should be deleted, it gives error
AMP unused argument - amp_get_eventes.py
‘filepath’ not used
--->
def write_events_to_file(filepath, ampevents):
with open(events_path, "w") as file:
json.dump(ampevents, file, indent=2)
solution not correct of threat grid mission
not correct, time should be wider. I changed it to
"/search/submissions?after=2010-07-18T21:39:13Z&q={}"
then I got 44 hits, otherwise not much...
umbrella pagination with get request not working - EnforcementGetRequest.py
"url_get" variable is not updated correctly in the while loop, causing the next page not to load.
https://github.com/CiscoDevNet/dne-security-code/blob/master/intro-umbrella/EnforcementGetRequest.py
Original code
# keep doing GET requests, until looped through all domains
while True:
req = requests.get(url_get)
json_file = req.json()
for row in json_file["data"]:
domain_list.append(row["name"])
# GET requests will only list 200 domains, if more than that, it will request next bulk of 200 domains
if bool(json_file["meta"]["next"]):
Url = json_file["meta"]["next"]
# break out of loop when finished
else:
break
Fixed code
# keep doing GET requests, until looped through all domains
while True:
req = requests.get(url_get)
json_file = req.json()
for row in json_file["data"]:
domain_list.append(row["name"])
# GET requests will only list 200 domains, if more than that, it will request next bulk of 200 domains
if bool(json_file["meta"]["next"]):
url_get = json_file["meta"]["next"]
# break out of loop when finished
else:
break
threat grid query time 180 days does not return data, needs to be changed to 360 days to work
AMP unused imports - amp_custom_detect.py
amp_custom_detect.py
import webexteamssdk
from crayons import green
camelCase in Umbrella mission, mixed with snake_case - umbrellamission.py
many uses of camelCase in https://github.com/CiscoDevNet/dne-security-code/blob/master/intro-umbrella/mission/umbrellamission.py
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.