using multiple conditions in iam policy - conditional-statements

I am trying to give two conditions StringEquals and ArnEquals. The StringEquals block is working whereas ArnEquals block is failing. Even after i gave the correct federated user of mine. I am unable to start build. here is what i am trying. I am getting the error the user with xxxx arn is not allowed to stratbuild action.
- Effect: Allow
Action:
- codebuild:StartBuild
- codebuild:StopBuild
- codeBuild:RetryBuild
Resource:
- !Sub arn:aws:codebuild:${AWS::Region}:${AWS::AccountId}:project/*
Condition:
StringEquals:
aws:ResourceTag/Application:
- yyy
- xxx
aws:ResourceTag/TargetEnvironmentType:
- dev
ArnEquals:
aws:SourceArn:
- !Sub arn:aws:sts::${AWS::AccountId}:federated-user/Builder-role/xxx#gmial.com

Related

Cakephp 4 Linking 2 existing entities with belongstomany association

First of all, thank you for your patience. I am getting to grips with PHP coding after a long while. I have finished the famous Cake tutorial and am now continuing with what I know and creating new solutions.
I am creating a voting system. When the current user votes on a suggestion (sames as an article), a new entry needs to be saved in a related cross table between suggestions and users. I thought that the public function link() is the best way to do this. See the function in the ArticlesController below. However, I get an error message "Call to undefined method Authentication\Identity::isNew()". This suggests I have not taken care of some authorization around this call. Can anyone tell me what I missed? Or whether there is a better way to do this?
Note; I do know it looks strange that when I already have my one suggestion I am working through the suggestions table, but I could not find a way for one entity to directly link it to an associated entity (ie I found no link function for entities). It would be nice to hear if this can be done in a leaner way.
public function upvote($id = null)
{
$suggestion = $this->Suggestions->get($id);
$this->Authorization->skipAuthorization();
$user = $this->request->getAttribute('identity');
//Create link between current suggestions and current user in the suggestions_users table
$suggestionsTable = $this->getTableLocator()->get('Suggestions');
$suggestionsTable->Users->link($suggestion,[$user]);
if ($voteTable->save($vote)) {
// The foreign key value was set automatically.
$this->Flash->success(__('Your vote has been cast.'));
}
else {
$this->Flash->error(__('The vote could not be cast. Apologies for the technical issue.'));
}
}
Stack trace;
2020-11-12 13:46:52 Error: [Error] Call to undefined method Authentication\Identity::isNew() in C:\wamp64\www\cake\vendor\cakephp\authorization\src\IdentityDecorator.php on line 125
Stack Trace:
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\ORM\Association\BelongsToMany.php:1323
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\ORM\Association\BelongsToMany.php:864
- C:\wamp64\www\cake\src\Controller\SuggestionsController.php:143
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Controller\Controller.php:529
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Controller\ControllerFactory.php:79
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\BaseApplication.php:251
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:77
- C:\wamp64\www\cake\vendor\cakephp\authorization\src\Middleware\AuthorizationMiddleware.php:129
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\authentication\src\Middleware\AuthenticationMiddleware.php:122
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Routing\Middleware\RoutingMiddleware.php:166
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Middleware\CsrfProtectionMiddleware.php:156
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Middleware\BodyParserMiddleware.php:159
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Routing\Middleware\RoutingMiddleware.php:166
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Routing\Middleware\AssetMiddleware.php:68
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Error\Middleware\ErrorHandlerMiddleware.php:121
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\debug_kit\src\Middleware\DebugKitMiddleware.php:60
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:58
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Server.php:90
- C:\wamp64\www\cake\webroot\index.php:40
Request URL: /suggestions/upvote/1
Referer URL: http://localhost:8000/cake/suggestions

Filebeat - kakfka output 'and' or 'regex' condition not working

kafka topic filter filebeat
Hi , I am trying to filter all messages containing indicator 'TEST01' from different log paths and send the messages to two different topics( topic1 and topic2) based on fields.type
If the fields.type is "first_test" then the messages should go to "topic1" else to "topic2" . Below is the code i tried - but the and: operator is not working. Appreciate any help on coding composite conditions in filebeat -dynamic kafka output . Thank you https://www.elastic.co/guide/en/beats/filebeat/master/defining-processors.html#condition-equals
topics:
- topic: "topic1"
and:
- when.contains:
message: "TEST01"
- equals:
fields.type: "first_test"
- topic: "topic2"
and:
- when.contains:
message: "TEST01"
- not:
equals:
fields.type: "first_test"
Got this work without and: operator but with below code using 'contains' and different fields.type. Still any answers on how to use and: , regex in context of my question will be helpful. thanks
topics:
- topic: "topic1"
- when.contains:
message: "TEST01"
fields.type: "first_test"
- topic: "topic2"
- when.contains:
message: "TEST01"
fields.type: "second_test

How to create a negative test case in GitHub

I am working on a repository in GitHub and learning to use their Workflows and Actions to execute CI tests. I have created a simple workflow that runs against a shell script to test a simple mathematical expression y-x=expected_val. This workflow isn't that different from other automatic tests I have set up on code in the past, but I cannot figure out how to perform negative test cases.
on:
push:
branches:
- 'Math-Test-Pass*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: T1. Successful math test
uses: ./.github/actions/mathTest
with:
OPERAND1: 3
OPERAND2: 5
ANSWER: 2
- name: T2. Mismatch answer math test
if: ${{ always() }}
uses: ./.github/actions/mathTest
with:
OPERAND1: -3
OPERAND2: 2
ANSWER: 1
- name: T3. Missing operand math test
if: ${{ always() }}
uses: ./.github/actions/mathTest
with:
OPERAND1: -3
ANSWER: 5
- name: T4. Another test should pass
if: ${{ always() }}
uses: ./.github/actions/mathTest
with:
OPERAND1: 6
OPERAND2: 9
ANSWER: 3
- name: T5. Another test should pass
uses: ./.github/actions/mathTest
with:
OPERAND1: 1
OPERAND2: 9
ANSWER: 8
Now, I expected tests T.2 and T.3 to fail, but I run into two problems. First, I want all the steps to execute and the errors thrown by T.2 and T.3 make the job status a failure. Github's default response is to not run any additional steps unless I force it with something like if: ${{ always() }} This means that T.3 and T.4 only run because of that logic and T.5 doesn't run at all. See below.
The second problem is that while the mathTest action failed on T.2 and T.3 that was the intended behavior. It did exactly what it was supposed to do by failing. I wanted to show that by improperly configuring the parameters the script would fail. These negative pass tests shouldn't show up as failures, but as successes. The whole math test should pass to show that the script in question was prompting the right errors as well as the right answers.
There is a third case that doesn't show here. I definitely don't want to use continue on error. If the script failed to throw an error I want the test case to fail. There should be a failure and then the rest of the tests should continue. My ideal solution would show a pass on T.2 and T.3 and run T.4 and T.5. The same solution would also fail on T.2 or T.3 if they didn't generate an exception and still run T.4 and T.5. I just don't know how to fix that.
I have considered a couple of options but I don't know what is usually done. I expect that while I could jury rig something (e.g. put the failure into the script as another parameter, nest the testing in a second script that passes the parameters and catches the error, etc.), there is some standard way of doing this that I haven't considered. I'm looking for anyone who can tell me how it should be done.
I obtained an answer from the GitHub community that I want to share here.
https://github.community/t/negative-testing-with-workflows/116559
The answer is that the workflow should kick off one of several tools instead of multiple actions and that the tools can handle positive/negative testing on their own. The example given by the respondent is https://github.com/lee-dohm/close-matching-issues/blob/c65bd332c8d7b63cc77e463d0103eed2ad6497d2/.github/workflows/test.yaml#L16 which uses npm for testing.

steps marked with trigger: status = failure, always run, even if status is success

I want to send notification in case any of the build step fails in drone ci. I tried adding following trigger at various levels, but it always runs, even in case of success.
Trigger that I am trying is as follows:
trigger:
status:
- failure
Tried setting it up inside/outside the steps. but it keeps getting triggered every time.
Try using where instead of trigger, like this:
- name: notify-me
image: ...
...
when:
status: [ failure ]

Players can't build in bPermissions

I have created my default group in bPermissions and the players that have the default rank can't build, I can't figure out why. I have even added the permission node "bpermissions.build". Here is the groups.yml:
default: default
groups:
default:
permissions:
- bpermissions.build
- essentials.afk
- essentials.afk.auto
- essentials.back
- essentials.home
- essentials.sethome
- essentials.spawn
- essentials.suicide
- mineconomy.balance.check
- mineconomy.bank.account.balance
- plotme.limit.1
- plotme.use.add
- plotme.use.auto
- plotme.use.buy
- plotme.use.protect
- plotme.use.remove
- warptastic.makesign
- warptastic.warp
groups: []
Please Help!
Try using the permission essentials.build
Your bpermissions.build is lowercase... Did you try uppercase?
As in: bPermissions.build
It's not the spawn area they're trying to build in, is it?
For bPermissions, you have to use the groups.yml in plugins/bPermissions/world-name, don't forget to set the other worlds to mirror the original world (same permissions for Nether and what not).
If that's the one you're using: are you SURE there isn't an issue with bPermissions and Essentials butting heads? Often mods won't work properly or certain functions fail to work due to them fighting.
On a side note, is there a reason you don't have the meta/priorities? It doesn't really matter right this second since you only have one group in this example, but add it if you plan on creating other groups like Mods and Admins or w/e.
I didn't need a permission for being able to build, it was enabled to all players by default o.o So I'm assuming that it's Essential permissions making it up or something xD If you want the building ability to be false for bPermissions, you'll have to tell it to be false.