Skip to content

Commit 8fa6adc

Browse files
author
Taras Keryk
committed
Merge branch 'master' into tk_tof3_prof_nam_bf
2 parents 5c6c2a3 + 6ba87e4 commit 8fa6adc

File tree

151 files changed

+9803
-2002
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+9803
-2002
lines changed

.DS_Store

-8 KB
Binary file not shown.

.bandit

Whitespace-only changes.

.github/workflows/bandit.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This workflow is to do the bandit check
2+
#
3+
4+
name: bandit
5+
on:
6+
pull_request:
7+
types:
8+
- opened
9+
- reopened
10+
- synchronize
11+
12+
jobs:
13+
bendit:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: bandit
18+
uses: jpetrucciani/bandit-check@master
19+
with:
20+
path: '.'

.github/workflows/semgrep.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Semgrep
2+
3+
on:
4+
pull_request: {}
5+
push:
6+
branches:
7+
- master
8+
- '201[7-9][0-1][0-9]'
9+
- '202[0-9][0-1][0-9]'
10+
11+
jobs:
12+
semgrep:
13+
name: Semgrep
14+
runs-on: ubuntu-latest
15+
container:
16+
image: returntocorp/semgrep
17+
steps:
18+
- uses: actions/checkout@v3
19+
- run: semgrep ci
20+
env:
21+
SEMGREP_RULES: p/default

README.md

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
[![Total alerts](https://img.shields.io/lgtm/alerts/g/Azure/sonic-utilities.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Azure/sonic-utilities/alerts/)
2-
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/Azure/sonic-utilities.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Azure/sonic-utilities/context:python)
1+
*static analysis:*
2+
3+
[![Total alerts](https://img.shields.io/lgtm/alerts/g/sonic-net/sonic-utilities.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/sonic-net/sonic-utilities/alerts/)
4+
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/sonic-net/sonic-utilities.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/sonic-net/sonic-utilities/context:python)
5+
6+
*sonic-utilities builds:*
7+
8+
[![master build](https://dev.azure.com/mssonic/build/_apis/build/status/Azure.sonic-utilities?branchName=master&label=master)](https://dev.azure.com/mssonic/build/_build/latest?definitionId=55&branchName=master)
9+
10+
[![202205 build](https://dev.azure.com/mssonic/build/_apis/build/status/Azure.sonic-utilities?branchName=202205&label=202205)](https://dev.azure.com/mssonic/build/_build/latest?definitionId=55&branchName=202205)
11+
12+
[![202012 build](https://dev.azure.com/mssonic/build/_apis/build/status/Azure.sonic-utilities?branchName=202012&label=202012)](https://dev.azure.com/mssonic/build/_build/latest?definitionId=55&branchName=202012)
313

4-
[![Build](https://sonic-jenkins.westus2.cloudapp.azure.com/job/common/job/sonic-utilities-build/badge/icon)](https://sonic-jenkins.westus2.cloudapp.azure.com/job/common/job/sonic-utilities-build/)
514

615
# SONiC: Software for Open Networking in the Cloud
716

@@ -33,7 +42,7 @@ Currently, this list of dependencies is as follows:
3342
- python-swsscommon_1.0.0_amd64.deb
3443

3544

36-
A convenient alternative is to let the SONiC build system configure a build enviroment for you. This can be done by cloning the [sonic-buildimage](https://github.com/Azure/sonic-buildimage) repo, building the sonic-utilities package inside the Debian Buster slave container, and staying inside the container once the build finishes. During the build process, the SONiC build system will build and install all the necessary dependencies inside the container. After following the instructions to clone and initialize the sonic-buildimage repo, this can be done as follows:
45+
A convenient alternative is to let the SONiC build system configure a build enviroment for you. This can be done by cloning the [sonic-buildimage](https://github.com/sonic-net/sonic-buildimage) repo, building the sonic-utilities package inside the Debian Buster slave container, and staying inside the container once the build finishes. During the build process, the SONiC build system will build and install all the necessary dependencies inside the container. After following the instructions to clone and initialize the sonic-buildimage repo, this can be done as follows:
3746

3847
1. Configure the build environment for an ASIC type (any type will do, here we use `generic`)
3948
```
@@ -71,13 +80,15 @@ A Debian package, containing data files needed by the utilities (bash_completion
7180
7281
#### To build
7382
74-
Instructions for building the sonic-utilities-data package can be found in [sonic-utilities-data/README.md](https://github.com/Azure/sonic-utilities/blob/master/sonic-utilities-data/README.md)
83+
Instructions for building the sonic-utilities-data package can be found in [sonic-utilities-data/README.md](https://github.com/sonic-net/sonic-utilities/blob/master/sonic-utilities-data/README.md)
7584
7685
---
7786
7887
## Contribution guide
7988
80-
All contributors must sign a contribution license agreement (CLA) before contributions can be accepted. This process is now automated via a GitHub bot when submitting new pull request. If the contributor has not yet signed a CLA, the bot will create a comment on the pull request containing a link to electronically sign the CLA.
89+
Please read the [contributor guide](https://github.com/sonic-net/SONiC/wiki/Becoming-a-contributor) for more details on how to contribute.
90+
91+
All contributors must sign an [Individual Contributor License Agreement (ICLA)](https://docs.linuxfoundation.org/lfx/easycla/v2-current/contributors/individual-contributor) before contributions can be accepted. This process is now automated via a GitHub bot when submitting new pull request. If the contributor has not yet signed a CLA, the bot will create a comment on the pull request containing a link to electronically sign the CLA.
8192
8293
### GitHub Workflow
8394

acl_loader/main.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import ipaddress
55
import json
66
import syslog
7+
import operator
78

89
import openconfig_acl
910
import tabulate
@@ -758,7 +759,7 @@ def incremental_update(self):
758759
namespace_configdb.mod_entry(self.ACL_RULE, key, None)
759760

760761
for key in existing_controlplane_rules:
761-
if cmp(self.rules_info[key], self.rules_db_info[key]) != 0:
762+
if not operator.eq(self.rules_info[key], self.rules_db_info[key]):
762763
self.configdb.set_entry(self.ACL_RULE, key, self.rules_info[key])
763764
# Program for per-asic namespace corresponding to front asic also if present.
764765
# For control plane ACL it's not needed but to keep all db in sync program everywhere
@@ -841,8 +842,10 @@ def show_session(self, session_name):
841842
val.get("monitor_port", ""), val.get("src_port", ""), val.get("direction", "").lower()])
842843

843844
print("ERSPAN Sessions")
845+
erspan_data = natsorted(erspan_data)
844846
print(tabulate.tabulate(erspan_data, headers=erspan_header, tablefmt="simple", missingval=""))
845847
print("\nSPAN Sessions")
848+
span_data = natsorted(span_data)
846849
print(tabulate.tabulate(span_data, headers=span_header, tablefmt="simple", missingval=""))
847850

848851
def show_policer(self, policer_name):

azure-pipelines.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ resources:
1010
repositories:
1111
- repository: sonic-swss
1212
type: github
13-
name: Azure/sonic-swss
14-
endpoint: build
13+
name: sonic-net/sonic-swss
14+
endpoint: sonic-net
1515

1616
stages:
1717
- stage: Build

config/aaa.py

+35-14
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
import ipaddress
33
import re
44
from swsscommon.swsscommon import ConfigDBConnector
5+
from .validated_config_db_connector import ValidatedConfigDBConnector
6+
from jsonpatch import JsonPatchConflict
57
import utilities_common.cli as clicommon
68

9+
ADHOC_VALIDATION = True
710
RADIUS_MAXSERVERS = 8
811
RADIUS_PASSKEY_MAX_LEN = 65
912
VALID_CHARS_MSG = "Valid chars are ASCII printable except SPACE, '#', and ','"
@@ -13,19 +16,27 @@ def is_secret(secret):
1316

1417

1518
def add_table_kv(table, entry, key, val):
16-
config_db = ConfigDBConnector()
19+
config_db = ValidatedConfigDBConnector(ConfigDBConnector())
1720
config_db.connect()
18-
config_db.mod_entry(table, entry, {key:val})
21+
try:
22+
config_db.mod_entry(table, entry, {key:val})
23+
except ValueError as e:
24+
ctx = click.get_current_context()
25+
ctx.fail("Invalid ConfigDB. Error: {}".format(e))
1926

2027

2128
def del_table_key(table, entry, key):
22-
config_db = ConfigDBConnector()
29+
config_db = ValidatedConfigDBConnector(ConfigDBConnector())
2330
config_db.connect()
2431
data = config_db.get_entry(table, entry)
2532
if data:
2633
if key in data:
2734
del data[key]
28-
config_db.set_entry(table, entry, data)
35+
try:
36+
config_db.set_entry(table, entry, data)
37+
except (ValueError, JsonPatchConflict) as e:
38+
ctx = click.get_current_context()
39+
ctx.fail("Invalid ConfigDB. Error: {}".format(e))
2940

3041
@click.group()
3142
def aaa():
@@ -246,11 +257,12 @@ def passkey(ctx, secret):
246257
@click.option('-m', '--use-mgmt-vrf', help="Management vrf, default is no vrf", is_flag=True)
247258
def add(address, timeout, key, auth_type, port, pri, use_mgmt_vrf):
248259
"""Specify a TACACS+ server"""
249-
if not clicommon.is_ipaddress(address):
250-
click.echo('Invalid ip address')
251-
return
260+
if ADHOC_VALIDATION:
261+
if not clicommon.is_ipaddress(address):
262+
click.echo('Invalid ip address') # TODO: MISSING CONSTRAINT IN YANG MODEL
263+
return
252264

253-
config_db = ConfigDBConnector()
265+
config_db = ValidatedConfigDBConnector(ConfigDBConnector())
254266
config_db.connect()
255267
old_data = config_db.get_entry('TACPLUS_SERVER', address)
256268
if old_data != {}:
@@ -268,7 +280,11 @@ def add(address, timeout, key, auth_type, port, pri, use_mgmt_vrf):
268280
data['passkey'] = key
269281
if use_mgmt_vrf :
270282
data['vrf'] = "mgmt"
271-
config_db.set_entry('TACPLUS_SERVER', address, data)
283+
try:
284+
config_db.set_entry('TACPLUS_SERVER', address, data)
285+
except ValueError as e:
286+
ctx = click.get_current_context()
287+
ctx.fail("Invalid ip address. Error: {}".format(e))
272288
tacacs.add_command(add)
273289

274290

@@ -278,13 +294,18 @@ def add(address, timeout, key, auth_type, port, pri, use_mgmt_vrf):
278294
@click.argument('address', metavar='<ip_address>')
279295
def delete(address):
280296
"""Delete a TACACS+ server"""
281-
if not clicommon.is_ipaddress(address):
282-
click.echo('Invalid ip address')
283-
return
297+
if ADHOC_VALIDATION:
298+
if not clicommon.is_ipaddress(address):
299+
click.echo('Invalid ip address')
300+
return
284301

285-
config_db = ConfigDBConnector()
302+
config_db = ValidatedConfigDBConnector(ConfigDBConnector())
286303
config_db.connect()
287-
config_db.set_entry('TACPLUS_SERVER', address, None)
304+
try:
305+
config_db.set_entry('TACPLUS_SERVER', address, None)
306+
except JsonPatchConflict as e:
307+
ctx = click.get_current_context()
308+
ctx.fail("Invalid ip address. Error: {}".format(e))
288309
tacacs.add_command(delete)
289310

290311

config/kube.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _update_kube_server(db, field, val):
2525
def_data = {
2626
KUBE_SERVER_IP: "",
2727
KUBE_SERVER_PORT: "6443",
28-
KUBE_SERVER_INSECURE: "False",
28+
KUBE_SERVER_INSECURE: "True",
2929
KUBE_SERVER_DISABLE: "False"
3030
}
3131
for f in def_data:

0 commit comments

Comments
 (0)