Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/SC4SNMP_UI_backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

load_dotenv()

__version__ = "1.2.3"
__version__ = "1.3.0-beta.1"

MONGO_URI = os.getenv("MONGO_URI")
log = logging.getLogger('gunicorn.error')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,15 @@ def convert(self, documents: list) -> dict:
:param documents: inventory from mongo
:return: dictionary that can be dumped to yaml
"""
inventory_string = "address,port,version,community,secret,security_engine,walk_interval,profiles,smart_profiles,delete"
inventory_string = "address,port,version,community,secret,security_engine,walk_interval,profiles,smart_profiles,max_oid_to_process,delete"
for inv in documents:
smart_profiles = bool_to_str(inv['smart_profiles'])
inv_delete = bool_to_str(inv['delete'])
max_oid_to_process = inv.get('max_oid_to_process')
max_oid_to_process = '' if max_oid_to_process is None else max_oid_to_process
inventory_string += f"\n{inv['address']},{inv['port']},{inv['version']},{inv['community']}," \
f"{inv['secret']},{inv['security_engine']},{inv['walk_interval']},{inv['profiles']}," \
f"{smart_profiles},{inv_delete}"
f"{smart_profiles},{max_oid_to_process},{inv_delete}"
return {
"inventory": literal_string(inventory_string)
}
Expand Down
5 changes: 4 additions & 1 deletion backend/SC4SNMP_UI_backend/common/backend_ui_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ def ui2backend(self, document: dict, **kwargs):
'walk_interval': document['walkInterval'],
'profiles': profiles,
'smart_profiles': document['smartProfiles'],
'max_oid_to_process': int(document['maxOidToProcess'])
if str(document.get('maxOidToProcess', "")).strip() else None,
'delete': kwargs['delete']
}
return result
Expand All @@ -303,6 +305,7 @@ def backend2ui(self, document: dict, **kwargs):
'securityEngine': document['security_engine'],
'walkInterval': document['walk_interval'],
'profiles': profiles,
'smartProfiles': document['smart_profiles']
'smartProfiles': document['smart_profiles'],
'maxOidToProcess': '' if document.get('max_oid_to_process') is None else document['max_oid_to_process']
}
return result
10 changes: 8 additions & 2 deletions backend/SC4SNMP_UI_backend/common/file_to_config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ def inventory_csv_to_documents(csv_string: str) -> list:
Inverse of InventoryToYamlDictConversion.convert. Parses the
poller.inventory literal-block CSV (header: address,port,version,
community,secret,security_engine,walk_interval,profiles,smart_profiles,
delete) into the inventory_ui Mongo document shape - one dict per row,
matching InventoryConversion.ui2backend's output fields.
max_oid_to_process,delete) into the inventory_ui Mongo document shape -
one dict per row, matching InventoryConversion.ui2backend's output fields.

max_oid_to_process is optional - a missing column (older section files)
or a blank cell both mean "unset" (None), so the connector falls back to
its global default rather than raising on int("").

Rows whose address is blank or starts with "#" are skipped, mirroring
the connector's own convention of allowing commented-out inventory rows.
Expand All @@ -59,6 +63,7 @@ def inventory_csv_to_documents(csv_string: str) -> list:
address = (row.get("address") or "").strip()
if not address or address.startswith("#"):
continue
max_oid_raw = (row.get("max_oid_to_process") or "").strip()
documents.append({
"address": address,
"port": int(row["port"]),
Expand All @@ -69,6 +74,7 @@ def inventory_csv_to_documents(csv_string: str) -> list:
"walk_interval": int(row["walk_interval"]),
"profiles": row["profiles"],
"smart_profiles": str_to_bool(row["smart_profiles"]),
"max_oid_to_process": int(max_oid_raw) if max_oid_raw else None,
"delete": str_to_bool(row["delete"]),
})
return documents
6 changes: 3 additions & 3 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
click==8.4.2
click==8.5.0
Flask==3.1.3
Flask-Cors==6.0.5
itsdangerous==2.2.0
Expand All @@ -8,7 +8,7 @@ pymongo==4.17.0
six==1.17.0
Werkzeug==3.1.8
pytest~=9.0, >=9.0.3
gunicorn==26.1.0
gunicorn==26.2.0
kubernetes~=36.0.3
python-dotenv~=1.2, >=1.2.2
PyYAML~=6.0
Expand All @@ -17,4 +17,4 @@ redis~=8.0
ruamel.yaml===0.17.32
PyJWT~=2.13
argon2-cffi~=25.1
Flask-Limiter~=3.8
Flask-Limiter~=4.1
9 changes: 7 additions & 2 deletions backend/tests/common/test_backend_ui_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def setUpClass(cls):
"security_engine": "1234aabbccd",
"profiles": "prof1;prof2;prof3",
"smart_profiles": False,
"max_oid_to_process": 50,
"delete": False
}

Expand All @@ -216,7 +217,8 @@ def setUpClass(cls):
"walkInterval": 1800,
"securityEngine": "1234aabbccd",
"profiles": ["prof1", "prof2", "prof3"],
"smartProfiles": False
"smartProfiles": False,
"maxOidToProcess": 50
}

cls.backend_inventory_2 = {
Expand All @@ -230,6 +232,7 @@ def setUpClass(cls):
"security_engine": "",
"profiles": "prof3",
"smart_profiles": True,
"max_oid_to_process": None,
"delete": True
}

Expand All @@ -244,7 +247,8 @@ def setUpClass(cls):
"walkInterval": 1900,
"securityEngine": "",
"profiles": ["prof3"],
"smartProfiles": True
"smartProfiles": True,
"maxOidToProcess": ""
}

def test_profile_backend_to_ui(self):
Expand Down Expand Up @@ -350,6 +354,7 @@ def test_inventory_ui_to_backend_empty_port_defaults_to_161(self):
"security_engine": "",
"profiles": "prof3",
"smart_profiles": True,
"max_oid_to_process": None,
"delete": True
}

Expand Down
30 changes: 30 additions & 0 deletions backend/tests/common/test_file_to_config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"walk_interval": 1800,
"profiles": "small_walk;in_profile",
"smart_profiles": True,
"max_oid_to_process": None,
"delete": False
},
{
Expand All @@ -112,6 +113,7 @@
"walk_interval": 1800,
"profiles": "single_metric;multiple_conditions",
"smart_profiles": False,
"max_oid_to_process": None,
"delete": False
}
]
Expand Down Expand Up @@ -151,6 +153,34 @@ def test_inventory_csv_to_documents_skips_commented_and_blank_rows(self):
self.assertEqual(len(documents), 1)
self.assertEqual(documents[0]["address"], "1.1.1.1")

def test_inventory_csv_to_documents_max_oid_to_process_backward_compat(self):
# Older section files predate the max_oid_to_process column entirely; a
# blank cell in a current-format file means the same thing (unset).
# Both must parse to None rather than raising, so the connector falls
# back to its global default.
old_format_csv = (
"address,port,version,community,secret,security_engine,walk_interval,profiles,smart_profiles,delete\n"
"1.1.1.1,161,2c,public,,,1800,small_walk,t,f\n"
)
documents = inventory_csv_to_documents(old_format_csv)
self.assertEqual(documents[0]["max_oid_to_process"], None)

blank_cell_csv = (
"address,port,version,community,secret,security_engine,walk_interval,profiles,smart_profiles,"
"max_oid_to_process,delete\n"
"1.1.1.1,161,2c,public,,,1800,small_walk,t,,f\n"
)
documents = inventory_csv_to_documents(blank_cell_csv)
self.assertEqual(documents[0]["max_oid_to_process"], None)

set_value_csv = (
"address,port,version,community,secret,security_engine,walk_interval,profiles,smart_profiles,"
"max_oid_to_process,delete\n"
"1.1.1.1,161,2c,public,,,1800,small_walk,t,50,f\n"
)
documents = inventory_csv_to_documents(set_value_csv)
self.assertEqual(documents[0]["max_oid_to_process"], 50)

def test_inventory_csv_to_documents_empty_string(self):
self.assertEqual(inventory_csv_to_documents(""), [])
self.assertEqual(inventory_csv_to_documents(None), [])
Expand Down
9 changes: 6 additions & 3 deletions backend/tests/ui_handling/get_endpoints/test_get_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ def test_get_inventory_list(m_cursor, m_groups, client):
"walkInterval": 1800,
"securityEngine": "1234aabbccd",
"profiles": ["prof1", "prof2", "prof3"],
"smartProfiles": False
"smartProfiles": False,
"maxOidToProcess": ""
},
{
"_id": common_id,
Expand All @@ -363,7 +364,8 @@ def test_get_inventory_list(m_cursor, m_groups, client):
"walkInterval": 1900,
"securityEngine": "",
"profiles": ["prof3"],
"smartProfiles": True
"smartProfiles": True,
"maxOidToProcess": ""
}
]

Expand All @@ -379,7 +381,8 @@ def test_get_inventory_list(m_cursor, m_groups, client):
"walkInterval": 1800,
"securityEngine": "1234aabbccd",
"profiles": ["prof1", "prof2", "prof3"],
"smartProfiles": False
"smartProfiles": False,
"maxOidToProcess": ""
},
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"security_engine": "1234aabbccd",
"profiles": "prof1;prof2;prof3",
"smart_profiles": False,
"max_oid_to_process": None,
"delete": False
}

Expand All @@ -55,6 +56,7 @@
"security_engine": "1234aabbccd",
"profiles": "prof1;prof2;prof3",
"smart_profiles": False,
"max_oid_to_process": None,
"delete": False
}

Expand Down Expand Up @@ -302,6 +304,7 @@ def test_edit_single_host_address_and_port_success(m_find, m_insert, m_update, m
"security_engine": "1234aabbccd",
"profiles": "prof1;prof2;prof3",
"smart_profiles": False,
"max_oid_to_process": None,
"delete": False
}
deleted_host_backend = {
Expand Down Expand Up @@ -383,6 +386,7 @@ def test_edit_ip_to_hostname_success(m_find, m_insert, m_update, m_delete, m_get
"security_engine": "1234aabbccd",
"profiles": "prof1;prof2;prof3",
"smart_profiles": False,
"max_oid_to_process": None,
"delete": False
}
deleted_host_backend = {
Expand Down Expand Up @@ -565,6 +569,7 @@ def test_edit_single_host_failed(m_find, m_insert, m_update, m_delete, m_get_inv
"security_engine": "1234aabbccd",
"profiles": "prof1;prof2;prof3",
"smart_profiles": False,
"max_oid_to_process": None,
"delete": False
}

Expand Down Expand Up @@ -939,6 +944,7 @@ def test_add_group_without_configuration_failure(m_find, m_insert, m_delete, cli
"security_engine": "1234aabbccd",
"profiles": "prof1;prof2;prof3",
"smart_profiles": False,
"max_oid_to_process": None,
"delete": False
}

Expand Down Expand Up @@ -1030,6 +1036,7 @@ def test_update_group_with_changing_name_success(m_find, m_insert, m_update, m_d
"security_engine": "1234aabbccd",
"profiles": "prof1;prof2;prof3",
"smart_profiles": False,
"max_oid_to_process": None,
"delete": False
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
{
"address": "1.1.1.1", "port": 161, "version": "2c", "community": "public", "secret": "",
"security_engine": "", "walk_interval": 1800, "profiles": "small_walk;in_profile",
"smart_profiles": True, "delete": False
"smart_profiles": True, "max_oid_to_process": None, "delete": False
},
{
"address": "group1", "port": 1161, "version": "2c", "community": "public", "secret": "",
"security_engine": "", "walk_interval": 1800, "profiles": "single_metric;multiple_conditions",
"smart_profiles": False, "delete": False
"smart_profiles": False, "max_oid_to_process": None, "delete": False
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def test_delete_profile_record(m_update, m_delete, m_find, client):
"security_engine": "1234aabbccd",
"profiles": "profile_2",
"smart_profiles": False,
"max_oid_to_process": None,
"delete": False
}

Expand Down Expand Up @@ -220,6 +221,7 @@ def test_update_profile_record_with_name_change_success(m_find, m_update, client
"security_engine": "1234aabbccd",
"profiles": "profile_1_edit;profile_2",
"smart_profiles": False,
"max_oid_to_process": None,
"delete": False
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
inventory: |-
address,port,version,community,secret,security_engine,walk_interval,profiles,smart_profiles,delete
1.1.1.1,161,2c,public,,,1800,small_walk;in_profile,t,f
group1,1161,2c,public,,,1800,single_metric;multiple_conditions,f,f
address,port,version,community,secret,security_engine,walk_interval,profiles,smart_profiles,max_oid_to_process,delete
1.1.1.1,161,2c,public,,,1800,small_walk;in_profile,t,,f
group1,1161,2c,public,,,1800,single_metric;multiple_conditions,f,,f
6 changes: 3 additions & 3 deletions backend/tests/yamls_for_tests/reference_files/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ poller:
# - sc4snmp-hlab-sha-aes
# - sc4snmp-hlab-sha-des
inventory: |-
address,port,version,community,secret,security_engine,walk_interval,profiles,smart_profiles,delete
1.1.1.1,161,2c,public,,,1800,small_walk;in_profile,t,f
group1,1161,2c,public,,,1800,single_metric;multiple_conditions,f,f
address,port,version,community,secret,security_engine,walk_interval,profiles,smart_profiles,max_oid_to_process,delete
1.1.1.1,161,2c,public,,,1800,small_walk;in_profile,t,,f
group1,1161,2c,public,,,1800,single_metric;multiple_conditions,f,,f
# group2,163,2c,public,,,3000,generic_switch,,
# 10.0.0.100,,3,,sc4snmp-hlab-sha-des,,1800,,,
sim:
Expand Down
2 changes: 1 addition & 1 deletion frontend/lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "1.2.3",
"version": "1.3.0-beta.1",
"command": {
"publish": {
"ignoreChanges": ["*.md"]
Expand Down
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"@sigstore/verify": "^4.1.2",
"@babel/plugin-transform-modules-systemjs": "^7.29.8",
"fast-uri": "^4.1.2",
"websocket-driver": "^0.7.5"
"websocket-driver": "^0.7.5",
"ws": "^8.21.0",
"qs": "^6.15.2"
}
}
8 changes: 4 additions & 4 deletions frontend/packages/manager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splunk/manager",
"version": "1.2.3",
"version": "1.3.0-beta.1",
"license": "UNLICENSED",
"scripts": {
"build": "NODE_ENV=production webpack --bail --config demo/webpack.standalone.config.js",
Expand All @@ -20,7 +20,7 @@
},
"main": "Manager.js",
"dependencies": {
"@splunk/react-ui": "^4.47.1",
"@splunk/react-ui": "^5.0.0",
"@splunk/themes": "^0.11.0",
"axios": "^1.16.0",
"css-loader": "^7.1.4",
Expand Down Expand Up @@ -63,7 +63,7 @@
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-test-renderer": "^16.12.0",
"styled-components": "5.1.1",
"styled-components": "5.3.11",
"stylelint": "^17.14.1",
"webpack": "^5.109.2",
"webpack-cli": "^7.2.2",
Expand All @@ -72,7 +72,7 @@
},
"peerDependencies": {
"react": "^16.8",
"styled-components": "5.1.1"
"styled-components": "5.3.11"
},
"engines": {
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
Expand Down
Loading
Loading