-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Azure:master' into route-flow-counter-1
- Loading branch information
Showing
49 changed files
with
808 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.7 BLOCK --> | ||
|
||
## Security | ||
|
||
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). | ||
|
||
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. | ||
|
||
## Reporting Security Issues | ||
|
||
**Please do not report security vulnerabilities through public GitHub issues.** | ||
|
||
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). | ||
|
||
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). | ||
|
||
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). | ||
|
||
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: | ||
|
||
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) | ||
* Full paths of source file(s) related to the manifestation of the issue | ||
* The location of the affected source code (tag/branch/commit or direct URL) | ||
* Any special configuration required to reproduce the issue | ||
* Step-by-step instructions to reproduce the issue | ||
* Proof-of-concept or exploit code (if possible) | ||
* Impact of the issue, including how an attacker might exploit the issue | ||
|
||
This information will help us triage your report more quickly. | ||
|
||
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. | ||
|
||
## Preferred Languages | ||
|
||
We prefer all communications to be in English. | ||
|
||
## Policy | ||
|
||
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). | ||
|
||
<!-- END MICROSOFT SECURITY.MD BLOCK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import os | ||
import pickle | ||
import cryptography.exceptions | ||
import time | ||
|
||
import ptf | ||
import scapy.all as scapy | ||
MACSEC_SUPPORTED = False | ||
if hasattr(scapy, "VERSION") and tuple(map(int, scapy.VERSION.split('.'))) >= (2, 4, 5): | ||
MACSEC_SUPPORTED = True | ||
if MACSEC_SUPPORTED: | ||
import scapy.contrib.macsec as scapy_macsec | ||
|
||
MACSEC_INFO_FILE = "macsec_info.pickle" | ||
|
||
MACSEC_INFOS = {} | ||
|
||
|
||
def __decap_macsec_pkt(macsec_pkt, sci, an, sak, encrypt, send_sci, pn, xpn_en=False, ssci=None, salt=None): | ||
sa = scapy_macsec.MACsecSA(sci=sci, | ||
an=an, | ||
pn=pn, | ||
key=sak, | ||
icvlen=16, | ||
encrypt=encrypt, | ||
send_sci=send_sci, | ||
xpn_en=xpn_en, | ||
ssci=ssci, | ||
salt=salt) | ||
try: | ||
pkt = sa.decrypt(macsec_pkt) | ||
except cryptography.exceptions.InvalidTag: | ||
# Invalid MACsec packets | ||
return None | ||
pkt = sa.decap(pkt) | ||
return pkt | ||
|
||
|
||
def __macsec_dp_poll(test, device_number=0, port_number=None, timeout=None, exp_pkt=None): | ||
recent_packets = [] | ||
packet_count = 0 | ||
if timeout is None: | ||
timeout = ptf.ptfutils.default_timeout | ||
while True: | ||
start_time = time.time() | ||
ret = __origin_dp_poll( | ||
test, device_number=device_number, port_number=port_number, timeout=timeout, exp_pkt=None) | ||
timeout -= time.time() - start_time | ||
# The device number of PTF host is 0, if the target port isn't a injected port(belong to ptf host), Don't need to do MACsec further. | ||
if isinstance(ret, test.dataplane.PollFailure) or exp_pkt is None or ret.device != 0: | ||
return ret | ||
pkt = scapy.Ether(ret.packet) | ||
if pkt[scapy.Ether].type != 0x88e5: | ||
if ptf.dataplane.match_exp_pkt(exp_pkt, pkt): | ||
return ret | ||
else: | ||
continue | ||
if ret.port in MACSEC_INFOS and MACSEC_INFOS[ret.port]: | ||
encrypt, send_sci, xpn_en, sci, an, sak, ssci, salt = MACSEC_INFOS[ret.port] | ||
pkt = __decap_macsec_pkt(pkt, sci, an, sak, encrypt, | ||
send_sci, 0, xpn_en, ssci, salt) | ||
if pkt is not None and ptf.dataplane.match_exp_pkt(exp_pkt, pkt): | ||
return ret | ||
recent_packets.append(pkt) | ||
packet_count += 1 | ||
if timeout <= 0: | ||
break | ||
return test.dataplane.PollFailure(exp_pkt, recent_packets,packet_count) | ||
|
||
|
||
if MACSEC_SUPPORTED and os.path.exists(MACSEC_INFO_FILE): | ||
with open(MACSEC_INFO_FILE, "rb") as f: | ||
MACSEC_INFOS = pickle.load(f, encoding="bytes") | ||
if MACSEC_INFOS: | ||
__origin_dp_poll = ptf.testutils.dp_poll | ||
ptf.testutils.dp_poll = __macsec_dp_poll |
Oops, something went wrong.