You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/12/12 13:04:02 UTC

[GitHub] [nifi-minifi-cpp] adamdebreceni opened a new pull request, #1471: MINIFICPP-2012 - Make free unconditional

adamdebreceni opened a new pull request, #1471:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1471

   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] szaszm closed pull request #1471: MINIFICPP-2012 - Make free unconditional

Posted by GitBox <gi...@apache.org>.
szaszm closed pull request #1471: MINIFICPP-2012 - Make free unconditional
URL: https://github.com/apache/nifi-minifi-cpp/pull/1471


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1471: MINIFICPP-2012 - Make free unconditional

Posted by GitBox <gi...@apache.org>.
szaszm commented on code in PR #1471:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1471#discussion_r1047284129


##########
libminifi/test/unit/OsUtilTests.cpp:
##########
@@ -0,0 +1,41 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "utils/OsUtils.h"
+#include "../TestBase.h"
+#include "../Catch.h"
+
+namespace org::apache::nifi::minifi::test {
+
+#ifdef WIN32
+TEST_CASE("Test userIdToUsername for well-known SIDs", "[OsUtils]") {
+  CHECK("Nobody" == minifi::utils::OsUtils::userIdToUsername("S-1-0-0"));
+  CHECK("Everyone" == minifi::utils::OsUtils::userIdToUsername("S-1-1-0"));
+  CHECK("Local" == minifi::utils::OsUtils::userIdToUsername("S-1-2-0"));
+  CHECK("Console Logon" == minifi::utils::OsUtils::userIdToUsername("S-1-2-1"));
+  CHECK("Creator Owner" == minifi::utils::OsUtils::userIdToUsername("S-1-3-0"));
+  CHECK("Creator Group" == minifi::utils::OsUtils::userIdToUsername("S-1-3-1"));
+  CHECK("CREATOR OWNER SERVER" == minifi::utils::OsUtils::userIdToUsername("S-1-3-2"));
+  CHECK("CREATOR GROUP SERVER" == minifi::utils::OsUtils::userIdToUsername("S-1-3-3"));
+  CHECK("OWNER RIGHTS" == minifi::utils::OsUtils::userIdToUsername("S-1-3-4"));
+  CHECK("NT SERVICE\\ALL SERVICES" == minifi::utils::OsUtils::userIdToUsername("S-1-5-80-0"));

Review Comment:
   I like the new version with the emptiness checks. We can possibly change them to checking actual values in MINIFICPP-2013.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1471: MINIFICPP-2012 - Make free unconditional

Posted by GitBox <gi...@apache.org>.
szaszm commented on code in PR #1471:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1471#discussion_r1047169874


##########
libminifi/test/unit/OsUtilTests.cpp:
##########
@@ -0,0 +1,41 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "utils/OsUtils.h"
+#include "../TestBase.h"
+#include "../Catch.h"
+
+namespace org::apache::nifi::minifi::test {
+
+#ifdef WIN32
+TEST_CASE("Test userIdToUsername for well-known SIDs", "[OsUtils]") {
+  CHECK("Nobody" == minifi::utils::OsUtils::userIdToUsername("S-1-0-0"));
+  CHECK("Everyone" == minifi::utils::OsUtils::userIdToUsername("S-1-1-0"));
+  CHECK("Local" == minifi::utils::OsUtils::userIdToUsername("S-1-2-0"));
+  CHECK("Console Logon" == minifi::utils::OsUtils::userIdToUsername("S-1-2-1"));
+  CHECK("Creator Owner" == minifi::utils::OsUtils::userIdToUsername("S-1-3-0"));
+  CHECK("Creator Group" == minifi::utils::OsUtils::userIdToUsername("S-1-3-1"));
+  CHECK("CREATOR OWNER SERVER" == minifi::utils::OsUtils::userIdToUsername("S-1-3-2"));
+  CHECK("CREATOR GROUP SERVER" == minifi::utils::OsUtils::userIdToUsername("S-1-3-3"));
+  CHECK("OWNER RIGHTS" == minifi::utils::OsUtils::userIdToUsername("S-1-3-4"));
+  CHECK("NT SERVICE\\ALL SERVICES" == minifi::utils::OsUtils::userIdToUsername("S-1-5-80-0"));

Review Comment:
   I managed to test this on a hungarian windows installation. It fails: https://pastebin.com/qHW8B7Et
   I prefer not to check in a failing test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a diff in pull request #1471: MINIFICPP-2012 - Make free unconditional

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on code in PR #1471:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1471#discussion_r1047179473


##########
libminifi/test/unit/OsUtilTests.cpp:
##########
@@ -0,0 +1,41 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "utils/OsUtils.h"
+#include "../TestBase.h"
+#include "../Catch.h"
+
+namespace org::apache::nifi::minifi::test {
+
+#ifdef WIN32
+TEST_CASE("Test userIdToUsername for well-known SIDs", "[OsUtils]") {
+  CHECK("Nobody" == minifi::utils::OsUtils::userIdToUsername("S-1-0-0"));
+  CHECK("Everyone" == minifi::utils::OsUtils::userIdToUsername("S-1-1-0"));
+  CHECK("Local" == minifi::utils::OsUtils::userIdToUsername("S-1-2-0"));
+  CHECK("Console Logon" == minifi::utils::OsUtils::userIdToUsername("S-1-2-1"));
+  CHECK("Creator Owner" == minifi::utils::OsUtils::userIdToUsername("S-1-3-0"));
+  CHECK("Creator Group" == minifi::utils::OsUtils::userIdToUsername("S-1-3-1"));
+  CHECK("CREATOR OWNER SERVER" == minifi::utils::OsUtils::userIdToUsername("S-1-3-2"));
+  CHECK("CREATOR GROUP SERVER" == minifi::utils::OsUtils::userIdToUsername("S-1-3-3"));
+  CHECK("OWNER RIGHTS" == minifi::utils::OsUtils::userIdToUsername("S-1-3-4"));
+  CHECK("NT SERVICE\\ALL SERVICES" == minifi::utils::OsUtils::userIdToUsername("S-1-5-80-0"));

Review Comment:
   I am open to suggestions on how to test this, @martinzink is right, that we should have some way of verifying this change, running the tests manually with drmemory would provide such an options, we could also commit this test without any actual verification (so without `CHECK` calls) but that would mean committing an otherwise noop test, although a simple comment could signal its purpose and prevent accidental removal in the future



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a diff in pull request #1471: MINIFICPP-2012 - Make free unconditional

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on code in PR #1471:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1471#discussion_r1046845372


##########
libminifi/test/unit/OsUtilTests.cpp:
##########
@@ -0,0 +1,41 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "utils/OsUtils.h"
+#include "../TestBase.h"
+#include "../Catch.h"
+
+namespace org::apache::nifi::minifi::test {
+
+#ifdef WIN32
+TEST_CASE("Test userIdToUsername for well-known SIDs", "[OsUtils]") {
+  CHECK("Nobody" == minifi::utils::OsUtils::userIdToUsername("S-1-0-0"));
+  CHECK("Everyone" == minifi::utils::OsUtils::userIdToUsername("S-1-1-0"));
+  CHECK("Local" == minifi::utils::OsUtils::userIdToUsername("S-1-2-0"));
+  CHECK("Console Logon" == minifi::utils::OsUtils::userIdToUsername("S-1-2-1"));
+  CHECK("Creator Owner" == minifi::utils::OsUtils::userIdToUsername("S-1-3-0"));
+  CHECK("Creator Group" == minifi::utils::OsUtils::userIdToUsername("S-1-3-1"));
+  CHECK("CREATOR OWNER SERVER" == minifi::utils::OsUtils::userIdToUsername("S-1-3-2"));
+  CHECK("CREATOR GROUP SERVER" == minifi::utils::OsUtils::userIdToUsername("S-1-3-3"));
+  CHECK("OWNER RIGHTS" == minifi::utils::OsUtils::userIdToUsername("S-1-3-4"));
+  CHECK("NT SERVICE\\ALL SERVICES" == minifi::utils::OsUtils::userIdToUsername("S-1-5-80-0"));

Review Comment:
   `userIdToUsername` first checks a fixed set of identifiers in `resolve_common_identifiers`, which returns english users, so if localization becomes an issue, this test will fail and we will have to look into `resolve_common_identifiers` as well, created a ticket to handle this: [MINIFICPP-2013](https://issues.apache.org/jira/browse/MINIFICPP-2013)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] martinzink commented on pull request #1471: MINIFICPP-2012 - Make free unconditional

Posted by GitBox <gi...@apache.org>.
martinzink commented on PR #1471:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1471#issuecomment-1346665510

   Awesome find :pray: thanks for digging this out.
   
   Could you please add the explanation here or in the Jira how this could cause a memory leak?
   
   Also adding a unit test like this somewhere could make it easier for reviewrs to verify the leak and the PR
   (resolving the [well-known SID-s](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers#well-known-sids) leak 3 bytes of memory before your PR and 0 after that :+1: )
   > #ifdef WIN32
   TEST_CASE("Check userIdToUsername for memory leak", "[OsUtilTests]") {
     minifi::utils::OsUtils::userIdToUsername("S-1-0-0");
     minifi::utils::OsUtils::userIdToUsername("S-1-1-0");
     minifi::utils::OsUtils::userIdToUsername("S-1-2-0");
     minifi::utils::OsUtils::userIdToUsername("S-1-2-1");
     minifi::utils::OsUtils::userIdToUsername("S-1-3-0");
     minifi::utils::OsUtils::userIdToUsername("S-1-3-1");
     minifi::utils::OsUtils::userIdToUsername("S-1-3-2");
     minifi::utils::OsUtils::userIdToUsername("S-1-3-3");
     minifi::utils::OsUtils::userIdToUsername("S-1-3-4");
     minifi::utils::OsUtils::userIdToUsername("S-1-4");
     minifi::utils::OsUtils::userIdToUsername("S-1-5");
     minifi::utils::OsUtils::userIdToUsername("S-1-5-80-0");
   }
   #endif


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1471: MINIFICPP-2012 - Make free unconditional

Posted by GitBox <gi...@apache.org>.
szaszm commented on code in PR #1471:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1471#discussion_r1046825301


##########
libminifi/test/unit/OsUtilTests.cpp:
##########
@@ -0,0 +1,41 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "utils/OsUtils.h"
+#include "../TestBase.h"
+#include "../Catch.h"
+
+namespace org::apache::nifi::minifi::test {
+
+#ifdef WIN32
+TEST_CASE("Test userIdToUsername for well-known SIDs", "[OsUtils]") {
+  CHECK("Nobody" == minifi::utils::OsUtils::userIdToUsername("S-1-0-0"));
+  CHECK("Everyone" == minifi::utils::OsUtils::userIdToUsername("S-1-1-0"));
+  CHECK("Local" == minifi::utils::OsUtils::userIdToUsername("S-1-2-0"));
+  CHECK("Console Logon" == minifi::utils::OsUtils::userIdToUsername("S-1-2-1"));
+  CHECK("Creator Owner" == minifi::utils::OsUtils::userIdToUsername("S-1-3-0"));
+  CHECK("Creator Group" == minifi::utils::OsUtils::userIdToUsername("S-1-3-1"));
+  CHECK("CREATOR OWNER SERVER" == minifi::utils::OsUtils::userIdToUsername("S-1-3-2"));
+  CHECK("CREATOR GROUP SERVER" == minifi::utils::OsUtils::userIdToUsername("S-1-3-3"));
+  CHECK("OWNER RIGHTS" == minifi::utils::OsUtils::userIdToUsername("S-1-3-4"));
+  CHECK("NT SERVICE\\ALL SERVICES" == minifi::utils::OsUtils::userIdToUsername("S-1-5-80-0"));

Review Comment:
   I believe these usernames are localized, so non-english installations will have different names there.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org