Git Product home page Git Product logo

stash-filehooks-plugin's Introduction

Introduction

An Atlassian Bitbucket Server plugin to check on various file attributes, like size, name.

File Size Hook Configuration

Installation

The plugin is available in the Atlassian Marketplace and can be installed directly in Bitbucket Server using the Universal Plugin Manager (UPM), see here for details.

Configuration

File Size Hook

In order to configure the hook on a project level go to your project and select Settings > Hooks -> File Size Hook.

In order to configure the hook on a repository level go to your repository and select Settings > Hooks > File Size Hook. The following example rejects all files larger then 1MB (1048576 bytes).

File Size Hook Configuration

File Name Hook

In order to configure the hook on a project level go to your project and select Settings > Merge checks > File Name Hook.

In order to configure the hook on a repostory level go to your repository and select Settings > Merge checks > File Name Hook. The following example rejects all files matching the pattern readme.md when the file is pushed or part of a merge request(pull request).

File Size Hook Configuration

Releases

3.3.2 (2018-04-15)

3.3.1 (2018-03-03)

3.3.0 (2018-02-28)

3.2.0 (2017-12-30)

3.1.0 (2017-11-26)

3.0.1 (2017-11-12)

3.0.0 (2017-05-07)

  • Compatibility with Bitbucket Server 5.0.x

2.4.0 (2016-09-09)

  • File Name Hook:
    • Checks the file name pattern also for merge requests(pull requests) and not only for pushes, thanks ellaz for providing the pull request.

2.3.1 (2016-08-31)

  • Fixes an issue with rollback commits and forced pushed to Bitbucket, thanks ar613 for providing a fix.

2.3.0 (2016-03-15)

  • Allows to specify branch name patterns for the File Size Hook and File Name Hook.

2.2.0 (2016-01-23)

  • Tag commits are now excluded

2.1.2 (2016-01-22)

2.1.1 (2015-10-18)

  • Allows to specify exclude patterns for the File Size Hook and File Name Hook.

2.1.0 (2015-10-18)

  • Allows to specify exclude patterns for the File Size Hook and File Name Hook.

2.0.0 (2015-09-29)

  • Compatibility with Bitbucket Server 4.0.x

1.1.0 (2015-03-15)

  • File Size Hook:
  • File Name Hook:
    • New hook which allows to check on the file name and reject pushes if files matches the specified pattern

1.0.0 (2015-01-15)

  • Reject commits containing files which exceed a configurable file size. Files can be identified by regular expressions.

Roadmap

License

   Copyright 2015 Christian Galsterer
   Copyright 2017 Motorola Solutions, Inc.

   Licensed 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.

stash-filehooks-plugin's People

Contributors

ar613 avatar christiangalsterer avatar lucamilanesio avatar raspy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stash-filehooks-plugin's Issues

Do not reject push with big file deletions

dd if=/dev/zero of=big.file bs=1024k count=1 # creating "big" file
git add big.file
git commit -m "+ big.file"
git push
# enable hook with limit 1024 bytes
git rm big.file
git commit -m "- big.file"
git push

remote: =================================
remote: File [big.file] is too large. Maximum allowed file size is 1024 bytes
remote: =================================
To ssh://[email protected]:7999/test/test.git
! [remote rejected] master -> master (pre-receive hook declined)

File Hook fails when repository is new - blocker

Hello,

I have updated Bitbucket to version 5.4.1 and updated File Hook to version 3.0.0.

I create a new repository and I activate the File Size Hook with regex

Include: .*
Size: 4096

I do a touch test for an empty file

git clone
git add --all
git commit -m "asd"
git push origin

the push fails and the bitbucket log shows:

2017-11-10 10:43:42,271 INFO  [threadpool:thread-2] brian @1EE93X5x643x7473x0 1eoaj33 10.XX.XX.XX "POST /scm/test/test.git/git-receive-pack HTTP/1.1" c.a.s.i.h.r.DefaultRepositoryHookService [TEST/test[703]] hook 'filesize-hook' vetoed the push request
2017-11-10 10:43:42,273 WARN  [threadpool:thread-2]  c.a.s.i.hook.DefaultHookService Hook socket I/O failed before the repository/hook could be identified
org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724)
        at com.atlassian.stash.internal.hook.DefaultBuiltInHookHandlerFactory.lambda$preReceive$0(DefaultBuiltInHookHandlerFactory.java:36)
        at com.atlassian.stash.internal.hook.DefaultHookService.doHandleRequest(DefaultHookService.java:303)
        at com.atlassian.stash.internal.hook.DefaultHookService.handleRequest(DefaultHookService.java:289)
        at com.atlassian.stash.internal.hook.DefaultHookService.handleRawRequest(DefaultHookService.java:230)
        at com.atlassian.stash.internal.hook.DefaultHookService$1.lambda$run$0(DefaultHookService.java:197)
        at com.atlassian.stash.internal.concurrent.DefaultTransferableStateManager$StateTransferringRunnable.run(DefaultTransferableStateManager.java:166)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.lang.Thread.run(Thread.java:748)
        ... 11 frames trimmed

I disable the file hook, I push and it works.

I reactivate the plugin, I do a new commit and it works again.

I saw someone had the same issue:
https://community.atlassian.com/t5/Product-Apps-discussions/Unable-to-push-branch-created-locally-when-File-Hooks-plugin-is/td-p/612681

and he modified the code to:

if (refChange.getFromHash().equals("0000000000000000000000000000000000000000")) { request = new CommitsBetweenRequest.Builder(repository) .include(refChange.getToHash()) .build(); } else { request = new CommitsBetweenRequest.Builder(repositoryHookRequest.getRepository()) .exclude(refChange.getFromHash()) .include(refChange.getToHash()) .build(); }

Regards

Don't reject tags?

So I have a git repo where there used to be some large .bak files. No current commits should point to them, but when we do a

git tag -a tagname
git push origin tagname

the filesize hook blocks tag commit based upon size.

I could work around this if there were a way to exclude specific files from the size filter (there are only 3), but my attempts to do so have failed.

More descriptive pull request veto message needed

If you have a file name pattern that is matched during a pull request, the merge button is disabled (vetoed) but the hover-over text and detailed message when merge is clicked on only lists the file names matched but not why they were vetoed. It should be a more descriptive message like "The following files in the merge matched the file name hook patterns defined: file1, file2"

Plugin crashes when pushing a branch delete

When you push a branch delete the plugin crashes with:

java.lang.IllegalStateException: At least one changeset ID must be provided to retrieve detailed commits
        at com.atlassian.stash.content.DetailedChangesetsRequest$Builder.buildChangesetIds(DetailedChangesetsRequest.java:119) ~[stash-api-3.6.0.jar:na]
        at com.atlassian.stash.content.DetailedChangesetsRequest$Builder.build(DetailedChangesetsRequest.java:83) ~[stash-api-3.6.0.jar:na]
        at org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook$7.get(FileSizeHook.java:146) ~[na:na]
        at com.atlassian.stash.util.PagedIterable.iterator(PagedIterable.java:23) ~[stash-util-3.6.0.jar:na]
        at com.google.common.collect.Iterables$8.iterator(Iterables.java:709) ~[guava-11.0.2-atlassian-01.jar:na]
        at com.google.common.collect.Iterables.iterators(Iterables.java:499) ~[guava-11.0.2-atlassian-01.jar:na]
        at com.google.common.collect.Iterables.access$100(Iterables.java:60) ~[guava-11.0.2-atlassian-01.jar:na]
        at com.google.common.collect.Iterables$2.iterator(Iterables.java:489) ~[guava-11.0.2-atlassian-01.jar:na]
        at com.google.common.collect.Iterables$3.next(Iterables.java:508) ~[guava-11.0.2-atlassian-01.jar:na]
        at com.google.common.collect.Iterables$3.next(Iterables.java:501) ~[guava-11.0.2-atlassian-01.jar:na]
        at com.google.common.collect.Iterators$5.hasNext(Iterators.java:544) ~[guava-11.0.2-atlassian-01.jar:na]
        at com.google.common.collect.Multimaps.index(Multimaps.java:1853) ~[guava-11.0.2-atlassian-01.jar:na]
        at com.google.common.collect.Multimaps.index(Multimaps.java:1784) ~[guava-11.0.2-atlassian-01.jar:na]
        at org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook.zipWithSize(FileSizeHook.java:112) ~[na:na]
        at org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook.getChanges(FileSizeHook.java:107) ~[na:na]
        at org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook.onReceive(FileSizeHook.java:81) ~[na:na]
        at com.atlassian.stash.internal.hook.repository.PreReceiveRepositoryHookAdapter$1.visit(PreReceiveRepositoryHookAdapter.java:38) [stash-service-impl-3.6.0.jar:na]
        at com.atlassian.stash.internal.hook.repository.PreReceiveRepositoryHookAdapter$1.visit(PreReceiveRepositoryHookAdapter.java:33) [stash-service-impl-3.6.0.jar:na]

which I imagine is because of the 00000 that you get as a ref.

Unable to push after upgrade to 3.3.0 version

  • Bitbucket server - version 5.8.1
  • File hook plugin - upgraded from 3.2.0 to 3.3.0

We are using only file name hook where we reject commit of two files to the specific list of branches. After upgrading the plugin to the latest version a strange error occurs which suppress push to the repository (even when none of the two files were committed)

2018-03-02 19:59:24,962 WARN [threadpool:thread-4] jan.padera @1MTB2V6x1199x300436x0 ftwzfc 172.20.1.55 SSH - git-receive-pack '/<repo>' c.a.s.i.h.r.DefaultRepositoryHookService [<repo>] Error calling com.atlassian.sta sh.internal.plugin.legacy.CompositeRepositoryHook.preUpdate (org.christiangalsterer.stash-filehooks-plugin:filename-hook) java.lang.IllegalStateException: At least one commit ID must be provided to retrieve changesets at com.atlassian.bitbucket.scm.ChangesetsCommandParameters.<init>(ChangesetsCommandParameters.java:26) at com.atlassian.bitbucket.scm.ChangesetsCommandParameters.<init>(ChangesetsCommandParameters.java:10) at com.atlassian.bitbucket.scm.ChangesetsCommandParameters$Builder.build(ChangesetsCommandParameters.java:75) at org.christiangalsterer.stash.filehooks.plugin.hook.ChangesetServiceImpl.lambda$getChangesets$0(ChangesetServiceImpl.java:106) at com.atlassian.bitbucket.util.PagedIterable.iterator(PagedIterable.java:27) at org.christiangalsterer.stash.filehooks.plugin.hook.ChangesetServiceImpl.getChanges(ChangesetServiceImpl.java:49) at org.christiangalsterer.stash.filehooks.plugin.hook.ChangesetServiceImpl.getChanges(ChangesetServiceImpl.java:37) at org.christiangalsterer.stash.filehooks.plugin.hook.FileNameHook.onReceive(FileNameHook.java:76) at com.atlassian.stash.internal.plugin.legacy.PreReceiveRepositoryHookAdapter.preUpdate(PreReceiveRepositoryHookAdapter.java:29) at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.lambda$preUpdate$2(CompositeRepositoryHook.java:76) at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.handlingExceptions(CompositeRepositoryHook.java:92) at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.preUpdate(CompositeRepositoryHook.java:75) at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:860) at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.lambda$preUpdate$4(DefaultRepositoryHookService.java:458) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:437) at com.atlassian.stash.internal.hook.DefaultBuiltInHookHandlerFactory.lambda$preReceive$0(DefaultBuiltInHookHandlerFactory.java:36) at com.atlassian.stash.internal.scm.git.GitQuarantineHelper.lambda$null$0(GitQuarantineHelper.java:89) at com.atlassian.stash.internal.hook.DefaultHookService.doHandleRequest(DefaultHookService.java:303) at com.atlassian.stash.internal.hook.DefaultHookService.handleRequest(DefaultHookService.java:289) at com.atlassian.stash.internal.hook.DefaultHookService.handleRawRequest(DefaultHookService.java:230) at com.atlassian.stash.internal.hook.DefaultHookService$1.lambda$run$0(DefaultHookService.java:197) at com.atlassian.stash.internal.concurrent.DefaultTransferableStateManager$StateTransferringRunnable.run(DefaultTransferableStateManager.java:166) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.lang.Thread.run(Thread.java:748) ... 26 frames trimmed

File Size detection seems not always to be working

We have a repo containing big (>> 1MB) *.xml-files which are not detected by the setting of Max 1 MB. However *cpp-files with size >> 1 MB are detected! Is there a Limitation on what the plgin detects? Is XML treted as binary and if so why isn't it detected nevertheless? Thanks for any support! Cheers, Andreas

Configure file hooks plugin at central or server level

Hi,

Currently, this plugin is configurable at each repository level.
We want to prevent all users from uploading large files, so we will have to configure it at central level or server level.

How can we configure it at server level and not provide access to project admins to change the default values.

Please guide us if anything is already available in market.
Can we configure the values globally and make the values (text fields) not editable?

Thanks,
Rakesh

File hook plugin prevents new local branches to be pushed to the remote

Hello,

The File Hooks Plugin version 3.0 is preventing new local branches to be pushed to the remote if the file name and/or file size hook are enabled:

git push -u origin feature/syee_local_branch_test
Total 0 (delta 0), reused 0 (delta 0)
remote: Communication breakdown with Bitbucket.
To ssh://dev-bitbucket/test/syee_test_repo_3.git
! [remote rejected] feature/syee_local_branch_test -> feature/syee_local_branch_test (pre-receive hook declined)
error: failed to push some refs to 'ssh://git@dev-bitbucket/test/syee_test_repo_3.git'

If the File Name and File Size Hooks are disabled, the push succeeds:

git push -u origin feature/syee_local_branch_test
Total 0 (delta 0), reused 0 (delta 0)
remote:
remote: Create pull request for feature/syee_local_branch_test:
<cut>

Sylvia

Filtering per file extension

I would like to set up higher limit for sql files then rest.

Please help me set it up.

I have done:
Include .\.sql size: 100000
Include .
size 5000 exclude .*\.sql

The version: 2.4.0 (We are still on BitBucket 4.14)

Thanks!

Pattern case insensitivity

Can't figure out the pattern expression as it does not appear to be standard regex.

I would expect pattern /\.(mp3|mp4)/gi to affect the following filetypes:

  • .mp3
  • .MP3
  • .Mp3
  • .mP3
  • .mp4
  • .MP4
  • .Mp4
  • .mP4

The pattern only affects .mp3 and .mp4. How would a user create a case insensitive pattern?

Exclude deleted files from the check

Let's say I'm using a check to see if a file exists in the commit list, let's say for arguments sake its.

development.env.

If we run our builder in production mode, this file will be automatically be removed and a production.env file will be created.

However if I've previously commited (but not pushed) the development.env file. The expression development.env in the file name exclude hook even though it's technically being removed.

I know with git you can tell what status the file is (deleted or added), is it possible to add the option to exclude deleted files from the check?

Can't roll back a commit with a force push

I tried to do a git push --force after rolling back the last commit and got this error:

remote: Hook org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook failed. Error:
remote: At least one commit ID must be provided to retrieve changesets
To ssh://[email protected]:7999/test/mergetest.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://[email protected]:7999/test/mergetest.git'

Implement MergeRequestCheck on the FileHooks plugin

Hi, I have implemented a MergeRequestCheck - The original plugin did not allow a hook on a merge request from a repository without hook settings to one with.
I would like to create a pull request with my changes, but do not have permissions. How can I do that?
Branch name- MergeRequestCheck

File hook should be available at Project level

From an administration point of view it would be better if the filehooks plugin was available at the project level in Bit Bucket rather than at the repository level.

When project administrators create new repositories they have to remember to enable the file hook plugin, whereas if it was enabled at project level the settings would be inherited from the project.

There are two plugins in Bit Bucket provided by Atlassian which work at the project level: Verify Committer and Reject Force Push

File name hook incorrectly prevents a merge whereby the source branch is from a private fork repository

For the following scenario:

  • File name hook enabled
  • Branch permissions configured to allow changes to specific individuals

The pull request is:

  • created from a fork repository whereby no one has access but the fork repository owner
  • files in the commit do not match the file name hook configuration

For the above pull request, the individual who has write access to the destination branch should be able to merge but the "Merge" button is grayed/disabled:

  • "Repository hook org.christiangalsterer.stash-filehooks-plugin:filename-hook failed" message is displayed when hovering over the grayed/disabled "Merge" button
  • "There is 1 issue preventing you from merging the pull request. You are not permitted to access this resource" message is displayed if the grayed/disabled "Merge" button is clicked.

The file name hook is incorrectly preventing the merge from occurring. If the fork repository owner grants read access to the individual who has write access to the destination branch, the "Merge" button is no longer grayed/disabled and can proceed with the merge.

Does not work with submodules..?

I've tried committing a submodule with one small file in it with the file size hook enabled with the following configuration:

Include: .*
Size: 500000000

But I get an error like the following:

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=manager-st push -v --set-upstream origin feature/windowsUI:feature/windowsUI
POST git-receive-pack (1029 bytes)
remote: Hook org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook failed. Error:
remote: '/usr/bin/git cat-file --batch-check' exited with code 0 saying: error: unable to find df2451e48dda98c8a0fe4827ed7565ebe841643a
Pushing to http://[email protected]/git/scm/fswg/fsw.git
To http://mydomain.com/git/scm/fswg/fsw.git
! [remote rejected] feature/windowsUI -> feature/windowsUI (pre-receive hook declined)
error: failed to push some refs to 'http://[email protected]/git/scm/fswg/fsw.git'

Is this a known issue, or am I missing something?

Thanks!

TextBox to add custom message

Can you add support for including a textbox where we could add the company/product specific comments so that it makes easier to developers why the commit was rejected.

FileSize Hook: NullPointerException when size is null

One of our users has reported a NullPointerException when pushing to a repository with the FileSize Hook enabled:
$ git push origin feature/test
Enter passphrase for key '/c/Users/John.Doe/.ssh/id_rsa':
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (17/17), 1.32 KiB | 450.00 KiB/s, done.
Total 17 (delta 14), reused 0 (delta 0)
remote: Repository hook org.christiangalsterer.stash-filehooks-plugin:filesize-hook failed
remote: java.lang.NullPointerException
To ssh://bitbucket.corp.com:7999/project/repo.git
! [remote rejected] feature/test -> feature/test (pre-receive hook declined)
error: failed to push some refs to 'ssh://[email protected]:7999/project/repo.git'

From the logs, I can see the following:
2018-03-13 15:05:18,795 DEBUG [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git rev-list --format=%H%x02%P%x02%aN%x02%aE%x02%at%x02%cN%x02%cE%x02%ct --no-min-parents --stdin --
2018-03-13 15:05:18,800 DEBUG [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git diff-tree -C -r --always --format=commit %H%n%H%x02%P%x02%aN%x02%aE%x02%at%x02%cN%x02%cE%x02%ct --root --stdin --
2018-03-13 15:05:18,803 DEBUG [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git cat-file --batch-check
2018-03-13 15:05:18,803 WARN [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.s.i.h.r.DefaultRepositoryHookService [PROJECT/repo[600]] Error calling com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.preUpdate (org.christiangalsterer.stash-filehooks-plugin:filesize-hook)
java.lang.NullPointerException: null
at java.util.HashMap.merge(HashMap.java:1225)
at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1553)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.christiangalsterer.stash.filehooks.plugin.hook.CachingResolver.batchResolve(CachingResolver.java:87)
at org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook.onReceive(FileSizeHook.java:82)
at com.atlassian.stash.internal.plugin.legacy.PreReceiveRepositoryHookAdapter.preUpdate(PreReceiveRepositoryHookAdapter.java:29)
at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.lambda$preUpdate$2(CompositeRepositoryHook.java:76)
at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.handlingExceptions(CompositeRepositoryHook.java:92)
at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.preUpdate(CompositeRepositoryHook.java:75)
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:798)
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:411)
at com.atlassian.stash.internal.hook.DefaultBuiltInHookHandlerFactory.lambda$preReceive$0(DefaultBuiltInHookHandlerFactory.java:36)
at com.atlassian.stash.internal.scm.git.GitQuarantineHelper.lambda$null$0(GitQuarantineHelper.java:89)
at com.atlassian.stash.internal.hook.DefaultHookService.doHandleRequest(DefaultHookService.java:303)
at com.atlassian.stash.internal.hook.DefaultHookService.handleRequest(DefaultHookService.java:289)
at com.atlassian.stash.internal.hook.DefaultHookService.handleRawRequest(DefaultHookService.java:230)
at com.atlassian.stash.internal.hook.DefaultHookService$1.lambda$run$0(DefaultHookService.java:197)
at com.atlassian.stash.internal.concurrent.DefaultTransferableStateManager$StateTransferringRunnable.run(DefaultTransferableStateManager.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.lang.Thread.run(Thread.java:748)
... 26 frames trimmed
2018-03-13 15:05:18,804 INFO [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.s.i.h.r.DefaultRepositoryHookService [PROJECT/repo[600]] hook 'filesize-hook' vetoed the push request
2018-03-13 15:05:18,808 DEBUG [ssh-scm-request-handler] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git receive-pack /data/bitbucket/5.6.2/data/shared/data/repositories/600
2018-03-13 15:05:18,808 DEBUG [ssh-scm-request-handler] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.b.scm.ssh.SshCommandExitHandler /usr/bin/git receive-pack /data/bitbucket/5.6.2/data/shared/data/repositories/600: (Exit code: 0)

We are running Bitbucket Server 5.6.2 and File Hooks plugin v3.3.1. I think this is possibly a repository-related issue as we have the File Size Hook enabled in 200+ repos and this is the only repos so far to report the problem. Have disabled the hook in this repo for now, but would be nice to understand what causes this as we appreciate the functionality the hook offers.

Any thoughts or suggestions appreciated.

Cannot be enabled in Bitbucket 6.0

Attempts to enable the hook in the latest bitbucket release (6.0) results in:

"This app failed to enable. Refer to the logs for more information."

Couldn't see anything obvious in the logs though ...

instructions for compiling latest version

Hi, I'm trying to build this plugin for bitbucket. If I run atlas-run it downloads a heap of stuff but nothing happens when I get to the local site.

I need to add it as we need the latest fix. So any instructions on building it would be great.

Thanks

Allow to define exclude patterns

Sometimes it is more convenient to also to specify an exclude pattern instead of a complicated exclude pattern. (See also discussion in #7)

Passing integer to file size hook via rest api fails with java.lang.ClassCastException

Using python and Bitbucket Server 4.2.0 (see exception log for more info)

I tried passing the following dict (gets converted to JSON) to the generic "enable" endpoint for hooks:

{u'pattern-1': u'.*',
u'size-1': 100000,
u'pattern-exclude-1': '',
u'pattern-branches-1': ''}

The problem is that "size-1" is an integer and not a string which makes the validation fail, the logs indicate that line 46 in FileSizeHookValidator.java is the problem:

try {
    int size = Integer.parseInt(settings.getString(SETTINGS_SIZE_PREFIX + i, ""));
    if (size < 1) {
        errors.addFieldError("size-" + i, i18n.getText("filesize-hook.error.size", "Size must be an integer value larger than 0"));
    }
} catch (NumberFormatException e) {
    errors.addFieldError(SETTINGS_SIZE_PREFIX + i, i18n.getText("filesize-hook.error.size", "Size must be an integer value larger than 0"));
}

When multiple size rules use the same size, only last rule is effective

If you provide more than one file size rule that use different regexes but the same size, only the last rule is effective. The main reason is that parsed rules are kept in map by allowed size, so the newly parsed rule overwrites previous rule that used the same size.

Incompatible with Bitbucket Data Center

The latest UPM update (3.0) marks this plugin is not compatible with the following text:

The currently installed app was a part of the deprecated Data Center program and the app version is now not Data Center compatible. Please update the app to a Data Center version.

According to Atlassian:

The latest UPM update (3.0.0) contains Data Center compatibility messaging, which is why you’re now seeing these messages.
You’re seeing these as Atlassian has launched a new class for marketplace data center to test if the add-ons are DC compatible. This is to ensure that those add-ons are not compromising performance of the instance. Please refer to the full announcement here A new class of Marketplace app has arrived.
As a result, you will encounter situation where the plugins are marked as incompatible. We’re still approving new apps daily as our vendors and partners update their apps to meet our new Data Center standards. Ultimately, Atlassian recommends you contact the vendor to determine compatibility at scale. For the apps released by us, we are currently working on releasing new versions but that could still take some time.
In most cases, the add-ons should still work and you won’t see any problems (as they’ve been working fine so far), but look out for any updates from vendors.

New branch creation causes the plugin to iterate over all changesets

We have a very large repo (over 100K changes, 10 years of history). If we enable the plugin, then pushing a new branch to the server basically causes the push to hang and eventually die, because it will check every commit since the beginning of time.

The above happens because Stash gives you a from hash of 000000 and a to hash of <sha>, which will give you all changesets when you do the iteration.

There's no good fix, but a good medium term fix will be to just add a limit to how many changes are requested for a new branch push (e.g. 100).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.