You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by bostko <gi...@git.apache.org> on 2016/06/07 07:10:23 UTC

[GitHub] brooklyn-server pull request #185: Fix/effectors

GitHub user bostko opened a pull request:

    https://github.com/apache/brooklyn-server/pull/185

    Fix/effectors

    For review.
    @ygy can you check it?

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/bostko/brooklyn-server fix/effectors

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/185.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #185
    
----
commit c22d0f903153e3cae6537b6c4cb289b36f236fbd
Author: Yavor Yanchev <ya...@yanchev.com>
Date:   2016-06-06T12:33:24Z

    BROOKLYN-282 Avoid showing secret effector parameters

commit 7b8b1ced32f5453fd11647970fd6cb746fc12d94
Author: Valentin Aitken <bo...@gmail.com>
Date:   2016-06-06T18:11:08Z

    Invoking effector with sensitive parameters unit test

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Fix/effectors

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66145442
  
    --- Diff: launcher/src/test/java/org/apache/brooklyn/giulauncher/effectors/TestEntityWithEffectors.java ---
    @@ -0,0 +1,33 @@
    +/*
    + * 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.
    + */
    +package org.apache.brooklyn.giulauncher.effectors;
    +
    +import org.apache.brooklyn.api.entity.ImplementedBy;
    +import org.apache.brooklyn.core.annotation.Effector;
    +import org.apache.brooklyn.core.annotation.EffectorParam;
    +import org.apache.brooklyn.core.test.entity.TestEntity;
    +
    +@ImplementedBy(TestEntityWithEffectorsImpl.class)
    +public interface TestEntityWithEffectors extends TestEntity {
    --- End diff --
    
    Why do we define this again in `launcher`? 
    
    The `launcher/pom.xml` already has a dependency on core's tests, so we should just be able to use them without duplicating:
    
            <dependency>
                <groupId>org.apache.brooklyn</groupId>
                <artifactId>brooklyn-core</artifactId>
                <version>${project.version}</version>
                <classifier>tests</classifier>
                <scope>test</scope>
            </dependency>



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Fix/effectors

Posted by bostko <gi...@git.apache.org>.
Github user bostko commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66115696
  
    --- Diff: rest/rest-api/src/main/java/org/apache/brooklyn/rest/domain/EffectorSummary.java ---
    @@ -61,6 +64,10 @@ public String getType() {
                 return type;
             }
     
    +        public boolean isSensitive() {
    --- End diff --
    
    What do you think about naming it `shouldSanitize`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server issue #185: Fix/effectors

Posted by bostko <gi...@git.apache.org>.
Github user bostko commented on the issue:

    https://github.com/apache/brooklyn-server/pull/185
  
    After when you have the code from this branch and brooklyn-ui you can use the blueprint bellow to check how it looks in the UI
    ```yaml
    location: localhost
    services:
    - type: org.apache.brooklyn.giulauncher.effectors.TestEntityWithEffectors
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Fix/effectors

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66116469
  
    --- Diff: core/src/test/java/org/apache/brooklyn/core/mgmt/internal/TestEntityWithEffectorsImpl.java ---
    @@ -0,0 +1,42 @@
    +/*
    + * 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.
    + */
    +package org.apache.brooklyn.core.mgmt.internal;
    +
    +import org.apache.brooklyn.core.annotation.EffectorParam;
    +import org.apache.brooklyn.core.test.entity.TestEntityImpl;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +public class TestEntityWithEffectorsImpl extends TestEntityImpl implements TestEntityWithEffectors {
    +    private static final Logger log = LoggerFactory.getLogger(EffectorUtils.class);
    --- End diff --
    
    EffectorUtils?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Hide sensitive parameters from effectors

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66235488
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/effector/BasicParameterType.java ---
    @@ -32,6 +32,7 @@
         private Class<T> type;
         private String description;
         private Boolean hasDefaultValue = null;
    +    private boolean shouldSanitize = false;
    --- End diff --
    
    Why include `shouldSanitize` here? It's private and thus never used.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Fix/effectors

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66115978
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/effector/BasicParameterType.java ---
    @@ -44,6 +45,7 @@ public BasicParameterType(Map<?, ?> arguments) {
             if (arguments.containsKey("type")) type = (Class<T>) arguments.get("type");
             if (arguments.containsKey("description")) description = (String) arguments.get("description");
             if (arguments.containsKey("defaultValue")) defaultValue = (T) arguments.get("defaultValue");
    +        if (arguments.containsKey("sensitive")) defaultValue = (T) arguments.get("sensitive");
    --- End diff --
    
    Mistakenly overwrites `defaultValue`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Fix/effectors

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66116549
  
    --- Diff: launcher/src/test/java/org/apache/brooklyn/giulauncher/effectors/TestEntityWithEffectorsImpl.java ---
    @@ -0,0 +1,43 @@
    +/*
    + * 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.
    + */
    +package org.apache.brooklyn.giulauncher.effectors;
    +
    +import org.apache.brooklyn.core.annotation.EffectorParam;
    +import org.apache.brooklyn.core.mgmt.internal.EffectorUtils;
    +import org.apache.brooklyn.core.test.entity.TestEntityImpl;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +public class TestEntityWithEffectorsImpl extends TestEntityImpl implements TestEntityWithEffectors {
    +    private static final Logger log = LoggerFactory.getLogger(EffectorUtils.class);
    --- End diff --
    
    Wrong class again.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Hide sensitive parameters from effectors

Posted by bostko <gi...@git.apache.org>.
Github user bostko commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66240170
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/effector/BasicParameterType.java ---
    @@ -32,6 +32,7 @@
         private Class<T> type;
         private String description;
         private Boolean hasDefaultValue = null;
    +    private boolean shouldSanitize = false;
    --- End diff --
    
    Sorry, you are right. It is needed only in `EffectorSummary.ParameterSummary`
    Check my commit now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Fix/effectors

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66146158
  
    --- Diff: api/src/main/java/org/apache/brooklyn/api/effector/ParameterType.java ---
    @@ -45,4 +47,6 @@
          * @return The default value for this parameter, if not supplied during an effector call.
          */
         public T getDefaultValue();
    +
    +    public boolean isSensitive();
    --- End diff --
    
    I really worry about adding this - do we actually respect it properly? In many places we just have a `ConfigBag` without the `ParameterType` definition, so we can only infer from the name whether it looks like a password/credential.
    
    If we include `isSensitive` here, then it will set a false expectation of what we'll do with it.
    
    Should we just rely on `sanitize`, and get rid of `isSensitive`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server issue #185: Hide sensitive parameters from effectors

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the issue:

    https://github.com/apache/brooklyn-server/pull/185
  
    Thanks @bostko - merging now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Fix/effectors

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66116186
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/effector/BasicParameterType.java ---
    @@ -44,6 +45,7 @@ public BasicParameterType(Map<?, ?> arguments) {
             if (arguments.containsKey("type")) type = (Class<T>) arguments.get("type");
             if (arguments.containsKey("description")) description = (String) arguments.get("description");
             if (arguments.containsKey("defaultValue")) defaultValue = (T) arguments.get("defaultValue");
    +        if (arguments.containsKey("sensitive")) defaultValue = (T) arguments.get("sensitive");
    --- End diff --
    
    Is it possible for the value in the map to be null? If yes then use `Boolean.TRUE.equals(args.get(..))`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Fix/effectors

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66145873
  
    --- Diff: api/src/main/java/org/apache/brooklyn/api/effector/ParameterType.java ---
    @@ -45,4 +47,6 @@
          * @return The default value for this parameter, if not supplied during an effector call.
          */
         public T getDefaultValue();
    +
    +    public boolean isSensitive();
    --- End diff --
    
    Given your question about naming `shouldSanitize` or `isSensitive`, let's mark this as `@Beta`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Fix/effectors

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66116298
  
    --- Diff: core/src/test/java/org/apache/brooklyn/core/mgmt/internal/TestEntityWithEffectors.java ---
    @@ -0,0 +1,34 @@
    +/*
    + * 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.
    + */
    +package org.apache.brooklyn.core.mgmt.internal;
    +
    +import org.apache.brooklyn.api.entity.ImplementedBy;
    +import org.apache.brooklyn.core.annotation.Effector;
    +import org.apache.brooklyn.core.annotation.EffectorParam;
    +import org.apache.brooklyn.core.test.entity.TestEntity;
    +
    +@ImplementedBy(TestEntityWithEffectorsImpl.class)
    +public interface TestEntityWithEffectors extends TestEntity {
    +    @Effector(description = "Reset User pass effetor")
    --- End diff --
    
    typo: `effetor`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Hide sensitive parameters from effectors

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-server/pull/185


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Fix/effectors

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66146520
  
    --- Diff: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/EffectorTransformer.java ---
    @@ -83,7 +84,8 @@ public static EffectorSummary effectorSummaryForCatalog(Effector<?> effector) {
                     .context(entity).timeout(ValueResolver.REAL_QUICK_WAIT).getMaybe();
                 return new ParameterSummary(parameterType.getName(), parameterType.getParameterClassName(), 
                     parameterType.getDescription(), 
    -                WebResourceUtils.getValueForDisplay(defaultValue.orNull(), true, false));
    +                WebResourceUtils.getValueForDisplay(defaultValue.orNull(), true, false),
    +                Sanitizer.IS_SECRET_PREDICATE.apply(parameterType.getName()));
    --- End diff --
    
    It looks like you added `parameterType.isSensitive`, but then don't use it here (and instead rely on `Sanitizer`). As I said in earlier comment, I think that's fine - in fact probably best to delete `isSensitive` if we're not going to use it everywhere.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #185: Fix/effectors

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/185#discussion_r66116521
  
    --- Diff: launcher/src/test/java/org/apache/brooklyn/giulauncher/effectors/TestEntityWithEffectors.java ---
    @@ -0,0 +1,33 @@
    +/*
    + * 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.
    + */
    +package org.apache.brooklyn.giulauncher.effectors;
    +
    +import org.apache.brooklyn.api.entity.ImplementedBy;
    +import org.apache.brooklyn.core.annotation.Effector;
    +import org.apache.brooklyn.core.annotation.EffectorParam;
    +import org.apache.brooklyn.core.test.entity.TestEntity;
    +
    +@ImplementedBy(TestEntityWithEffectorsImpl.class)
    +public interface TestEntityWithEffectors extends TestEntity {
    +    @Effector(description = "Reset User pass effetor")
    --- End diff --
    
    `effetor` here and below again.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---