Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1050: Redfish: Check snmpTrap port #688

Merged
merged 1 commit into from
May 24, 2023
Merged

Conversation

ChicagoDuan
Copy link
Member

@ChicagoDuan ChicagoDuan commented May 17, 2023

Check snmpTrap port

  1. Allow empty port, eg:
    "snmp://9.41.166.76:".
  2. Invalid ports and out of range ports are not allowed, eg:
    "snmp://9.41.166.76:ab"
    "snmp://9.41.166.76:-40"
    "snmp://9.41.166.76:65536".

Test:

1. Empty port:
curl -k -H "X-Auth-Token: $bmc_token" -X POST -D headers.txt
 https://${bmc}/redfish/v1/EventService/Subscriptions
-d '{"Destination":"snmp://9.41.166.76:",
 "SubscriptionType":"SNMPTrap", "Protocol":"SNMPv2c"}'
{
  "@Message.ExtendedInfo": [
    {
      "@odata.type": "#Message.v1_1_1.Message",
      "Message": "The resource has been created successfully.",
      "MessageArgs": []

,
      "MessageId": "Base.1.13.0.Created",
      "MessageSeverity": "OK",
      "Resolution": "None."
    }
  ]
}

2. Invalid port:
curl -k -H "X-Auth-Token: $bmc_token" -X POST -D headers.txt
 https://${bmc}/redfish/v1/EventService/Subscriptions
 -d '{"Destination":"snmp://9.41.166.76:ab",
 "SubscriptionType":"SNMPTrap", "Protocol":"SNMPv2c"}'
{
  "Destination@Message.ExtendedInfo": [
    {
      "@odata.type": "#Message.v1_1_1.Message",
      "Message": "The value 'snmp://9.41.166.76:ab' for the property Destination is of a different format than the property can accept.",
      "MessageArgs": [
        "snmp://9.41.166.76:ab",
        "Destination"
      ],
      "MessageId": "Base.1.13.0.PropertyValueFormatError",
      "MessageSeverity": "Warning",
      "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed."
    }
  ]

curl -k -H "X-Auth-Token: $bmc_token" -X POST -D headers.txt
 https://${bmc}/redfish/v1/EventService/Subscriptions
 -d '{"Destination":"snmp://9.41.166.76:-40",
 "SubscriptionType":"SNMPTrap", "Protocol":"SNMPv2c"}'
{
  "Destination@Message.ExtendedInfo": [
    {
      "@odata.type": "#Message.v1_1_1.Message",
      "Message": "The value 'snmp://9.41.166.76:-40' for the property Destination is of a different format than the property can accept.",
      "MessageArgs": [
        "snmp://9.41.166.76:-40",
        "Destination"
      ],
      "MessageId": "Base.1.13.0.PropertyValueFormatError",
      "MessageSeverity": "Warning",
      "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed."
    }
  ]
}

3. Out of range port:
curl -k -H "X-Auth-Token: $bmc_token" -X POST -D headers.txt
 https://${bmc}/redfish/v1/EventService/Subscriptions
 -d '{"Destination":"snmp://9.41.166.76:65536",
 "SubscriptionType":"SNMPTrap", "Protocol":"SNMPv2c"}'
{
  "Destination@Message.ExtendedInfo": [
    {
      "@odata.type": "#Message.v1_1_1.Message",
      "Message": "The value 'snmp://9.41.166.76:65536' for the property Destination is of a different format than the property can accept.",
      "MessageArgs": [
        "snmp://9.41.166.76:65536",
        "Destination"
      ],
      "MessageId": "Base.1.13.0.PropertyValueFormatError",
      "MessageSeverity": "Warning",
      "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed."
    }
  ]
}

@ChicagoDuan ChicagoDuan force-pushed the 1050snmp branch 5 times, most recently from 408b0a2 to b80464f Compare May 17, 2023 09:28
@ChicagoDuan
Copy link
Member Author

CI failed because this patch(1050 clang16) is not merged: #687

Check snmpTrap port
1. Allow empty port, eg:
   "snmp://9.41.166.76:".
2. Invalid ports and

 out of range ports are not allowed, eg:
   "snmp://9.41.166.76:ab"
   "snmp://9.41.166.76:-40"
   "snmp://9.41.166.76:65536".

Test:
1. Empty port:
curl -k -H "X-Auth-Token: $bmc_token" -X POST -D headers.txt
 https://${bmc}/redfish/v1/EventService/Subscriptions
-d '{"Destination":"snmp://9.41.166.76:",
 "SubscriptionType":"SNMPTrap", "Protocol":"SNMPv2c"}'
{
  "@Message.ExtendedInfo": [
    {
      "@odata.type": "#Message.v1_1_1.Message",
      "Message": "The resource has been created successfully.",
      "MessageArgs": []

,
      "MessageId": "Base.1.13.0.Created",
      "MessageSeverity": "OK",
      "Resolution": "None."
    }
  ]
}

2. Invalid port:
curl -k -H "X-Auth-Token: $bmc_token" -X POST -D headers.txt
 https://${bmc}/redfish/v1/EventService/Subscriptions
 -d '{"Destination":"snmp://9.41.166.76:ab",
 "SubscriptionType":"SNMPTrap", "Protocol":"SNMPv2c"}'
{
  "Destination@Message.ExtendedInfo": [
    {
      "@odata.type": "#Message.v1_1_1.Message",
      "Message": "The value 'snmp://9.41.166.76:ab' for the property

 Destination is of a different format than the property can accept.",
      "MessageArgs": [
        "snmp://9.41.166.76:ab",
        "Destination"
      ],
      "MessageId": "Base.1.13.0.PropertyValueFormatError",
      "MessageSeverity": "Warning",
      "Resolution": "Correct the value for the property in the request
 body and resubmit the request if the operation failed."
    }
  ]

curl -k -H "X-Auth-Token: $bmc_token" -X POST -D headers.txt
 https://${bmc}/redfish/v1/EventService/Subscriptions
 -d '{"Destination":"snmp://9.41.166.76:-40",
 "SubscriptionType":"SNMPTrap", "Protocol":"SNMPv2c"}'
{
  "Destination@Message.ExtendedInfo": [
    {
      "@odata.type": "#Message.v1_1_1.Message",
      "Message": "The value 'snmp://9.41.166.76:-40' for the property
 Destination is of a different format than the property can accept.",
      "MessageArgs": [
        "snmp://9.41.166.76:-40",
        "Destination"
      ],
      "MessageId": "Base.1.13.0.PropertyValueFormatError",
      "MessageSeverity": "Warning",
      "Resolution": "Correct the value for the property in the request
 body and resubmit the request if the operation failed."
    }
  ]
}

3. Out of range port:
curl -k -H "X-Auth-Token: $bmc_token" -X POST -D headers.txt
 https://${bmc}/redfish/v1/EventService/Subscriptions
 -d '{"Destination":"snmp://9.41.166.76:65536",
 "SubscriptionType":"SNMPTrap", "Protocol":"SNMPv2c"}'
{
  "Destination@Message.ExtendedInfo": [
    {
      "@odata.type": "#Message.v1_1_1.Message",
      "Message": "The value 'snmp://9.41.166.76:65536' for the property
 Destination is of a different format than the property can accept.",
      "MessageArgs": [
        "snmp://9.41.166.76:65536",
        "Destination"
      ],
      "MessageId": "Base.1.13.0.PropertyValueFormatError",
      "MessageSeverity": "Warning",
      "Resolution": "Correct the value for the property in the request
 body and resubmit the request if the operation failed."
    }
  ]
}

Signed-off-by: Chicago Duan <duanzhijia01@inspur.com>
@gtmills
Copy link
Contributor

gtmills commented May 23, 2023

@ChicagoDuan Is there an upstream change here ?

@ChicagoDuan
Copy link
Member Author

@ChicagoDuan Is there an upstream change here ?

Yes, upstream has the same problem, I will push it to the upstream.

@rfrandse rfrandse merged commit 4842d3e into ibm-openbmc:1050 May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants